Ubuntu – How to change file permissions when booted from a live disk/stick

bootfstabpermissions

Let me start by saying that I am new to Ubuntu so please forgive my inexperience. Also, this question goes along with my question I posted on 5/15/2017 titled: Fstab edit crashed system.

THE PROBLEM

I can not save the edit to my /etc/fstab file while booting from a live disk.

When I open the /etc/fstab file with gedit as root, this is the header information I see:

*fstab [Read-Only] (491 GB Volume /media/ubuntu/0823c4f5-e42b-45ee-97b8-ad5d424b8b  

MY QUESTION

How can I change the file permission of /etc/fstab file to read – write in order to allow me to edit and save it while booting from a live disk?


EDIT UPDATE 5/21/2017

I am trying to apply sudodus solution (Thank You) to my issue, and I am not positive on how to proceed. Below is the result of me running his code to Identify the partition:

root@ubuntu:~# sudo lsblk -o model,size,name,fstype,label,mountpoint
MODEL     SIZE NAME   FSTYPE  LABEL                    MOUNTPOINT
TOSHIBA 465.8G sda                                     
      487M ├─sda1 ext2                             /media/ubuntu/99ee9dc0-67
        1K ├─sda2                                  
    465.3G └─sda5 LVM2_me                          
    457.3G   ├─ubuntu--vg-root
             │    ext4                             /media/ubuntu/0823c4f5-e4
        8G   └─ubuntu--vg-swap_1
                  swap                             
WDC WD1 931.5G sdb                                     
    931.5G └─sdb1                                  
ST4000D   3.7T sdc                                     
      128M ├─sdc1                                  
      3.7T └─sdc2 ext4    Seagate D1               /media/ubuntu/Seagate D1
ST4000D   3.7T sdd                                     
      128M ├─sdd1                                  
      3.7T └─sdd2 ext4    Seagate D2               /media/ubuntu/Seagate D2
DVD-ROM   1.4G sr0    iso9660 Ubuntu 16.04.1 LTS amd64 /cdrom
      1.4G loop0  squashf                          /rofs

My next step would be to Mount the partition using the information above, which I believe I needed to mount sda5, so I ran the following:

sudo mount /dev/sda5 /mnt

However, I then get the following:

root@ubuntu:~# sudo mount /dev/sda5 /mnt
mount: unknown filesystem type 'LVM2_member'

New Questions

  1. Is sda5 the correct mount point, and did I type the command correctly?
  2. What is this unknown filesystem type 'LVM2_member'?

EDIT UPDATE 5/22/2017

PROBLEM SOLVED

I was able to save my edit to my /etc/fstab file while booting from a live disk by following the comment left by @mook765, and then following the next steps suggested by @sudodus.

The partition I needed to mount was indeed a logical partition (LVM@_member). I was able to mount it with:

sudo mount /dev/mapper/ubuntu--vg-root /mnt

After that, I was able to edit and save the /etc/fstab file, which fixed the problem I had with my question I posted on 5/15/2017 titled: Fstab edit crashed system.

A very huge THANK YOU to @mook765 and @sudodus for all of your help! I do not think I could have gotten my system back up and running without it.

I will be researching and reading much more on how to edit the fstab file before trying this again.

Best Answer

I booted from a [persistent] live drive and could edit fstab in an installed system (both systems are 16.04.1) according to the following dialogue.

  • Identify the partition

    ubuntu@ubuntu:~$ sudo lsblk -o model,size,name,fstype,label,mountpoint
    MODEL              SIZE NAME        FSTYPE   LABEL                    MOUNTPOINT
    Samsung SSD 850  232.9G sda                                           
                       300M ├─sda1      vfat     EFI                      
                         1M ├─sda2                                        
                       100G ├─sda3      ext4     root                     
                         5G └─sda4      swap                              [SWAP]
                       1.4G loop0       squashfs                          /rofs
                      29.7G mmcblk0                                       
                         7G ├─mmcblk0p1 ntfs     usbdata                  /media/ubuntu/usbdata
                         1K ├─mmcblk0p2                                   
                       122M ├─mmcblk0p3 vfat     usbboot                  /media/ubuntu/usbboot
                       1.4G ├─mmcblk0p4 iso9660  Ubuntu 16.04.1 LTS amd64 /media/ubuntu/Ubuntu 16.04.1 LTS amd64
                      21.1G └─mmcblk0p5 ext4     casper-rw                /media/ubuntu/casper-rw
    
  • Mount the partition

    ubuntu@ubuntu:~$ sudo mount /dev/sdxn /mnt
    

    where x is the drive letter and n is the partition number. In my case:

    ubuntu@ubuntu:~$ sudo mount /dev/sda3 /mnt
    
  • List the file with the permissions

    ubuntu@ubuntu:~$ sudo ls -l /mnt/etc/fstab
    -rw-r--r-- 1 root root 717 Apr 30  2016 /mnt/etc/fstab
    
  • Back it up

    ubuntu@ubuntu:~$ sudo cp -p /mnt/etc/fstab /mnt/etc/fstab.bak
    
  • Edit /mnt/etc/fstab with root (superuser) privileges

    ubuntu@ubuntu:~$ sudo nano /mnt/etc/fstab
    
  • Check versus the backup file

    ubuntu@ubuntu:~$ sudo diff /mnt/etc/fstab /mnt/etc/fstab.bak
    14d13
    < # added this line for demo
    
  • List the file and its backup file

    ubuntu@ubuntu:~$ sudo ls -l /mnt/etc/fstab*
    -rw-r--r-- 1 root root 744 May 20 15:54 /mnt/etc/fstab
    -rw-r--r-- 1 root root 717 Apr 30  2016 /mnt/etc/fstab.bak
    ubuntu@ubuntu:~$ 
    
  • Comment: So the edit was successful. The modified version was written.

Related Question