Ubuntu: Persistent Ubuntu on a USB doesn't persist the data



Question:

I followed this article: Create a persistent Ubuntu USB which boots to RAM so I can have Ubuntu running from a USB and it will persist any changes I make.

The problem is it doesn't persist - I created a text file, saved it, and shut down. Than I boot my laptop, pick the USB from the menu, I see the Ubuntu OS but the file is gone. I tried the first option (using the hard drive) and the second (using the RAM).

enter image description here

Edit: Here is the output that was requested in the comments

ubuntu@ubuntu:~$ df -h ; sudo lsblk -f ; sudo lsblk -m ; echo "hello world" > hello.txt  Filesystem      Size  Used Avail Use% Mounted on  udev            3.8G     0  3.8G   0% /dev  tmpfs           767M  9.5M  757M   2% /run  /dev/sdb4       1.5G  1.5G     0 100% /cdrom  /dev/loop0      1.4G  1.4G     0 100% /rofs  aufs            3.8G   35M  3.8G   1% /  tmpfs           3.8G   26M  3.8G   1% /dev/shm  tmpfs           5.0M  4.0K  5.0M   1% /run/lock  tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup  tmpfs           3.8G  580K  3.8G   1% /tmp  tmpfs           767M   76K  767M   1% /run/user/999  /dev/sdb5       2.5G  3.9M  2.3G   1% /media/ubuntu/99b89b3c-5035-4a32-bf5a-514640fc7493  /dev/sdb1        11G   53M   11G   1% /media/ubuntu/usbdata  NAME   FSTYPE  LABEL             UUID                                 MOUNTPOINT  sdb                                                                    â"œâ"€sdb4 iso9660 Ubuntu 16.04.2 LTS amd64  â"‚                                2017-02-15-21-44-13-00               /cdrom  â"œâ"€sdb2                                                                 â"œâ"€sdb5 ext4                      99b89b3c-5035-4a32-bf5a-514640fc7493 /media/ubu  â"œâ"€sdb3 vfat    usbboot           E2B5-7A49                             â""â"€sdb1 ntfs    usbdata           25FB337F388A948A                     /media/ubu  loop0  squashf                                                        /rofs  sda                                                                    â"œâ"€sda2                                                                 â"œâ"€sda5 swap                      6fa9b4a3-962f-4677-8055-e5192e2f1fb3 [SWAP]  â""â"€sda1 ext4                      7edab5f8-81d1-45c8-93de-cf3dfe74d152  NAME     SIZE OWNER GROUP MODE  sdb     14.3G root  disk  brw-rw----  â"œâ"€sdb4   1.5G root  disk  brw-rw----  â"œâ"€sdb2     1M root  disk  brw-rw----  â"œâ"€sdb5   2.6G root  disk  brw-rw----  â"œâ"€sdb3   122M root  disk  brw-rw----  â""â"€sdb1  10.2G root  disk  brw-rw----  loop0    1.4G root  disk  brw-rw----  sda    223.6G root  disk  brw-rw----  â"œâ"€sda2     1K root  disk  brw-rw----  â"œâ"€sda5   7.7G root  disk  brw-rw----  â""â"€sda1 215.9G root  disk  brw-rw----      --------      ubuntu@ubuntu:~$ df -h ; sudo lsblk -f ; cat hello.txt  Filesystem      Size  Used Avail Use% Mounted on  udev            3.8G     0  3.8G   0% /dev  tmpfs           767M  9.5M  757M   2% /run  /dev/sdb4       1.5G  1.5G     0 100% /cdrom  /dev/loop0      1.4G  1.4G     0 100% /rofs  aufs            3.8G   35M  3.8G   1% /  tmpfs           3.8G   26M  3.8G   1% /dev/shm  tmpfs           5.0M  4.0K  5.0M   1% /run/lock  tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup  tmpfs           3.8G  580K  3.8G   1% /tmp  tmpfs           767M   68K  767M   1% /run/user/999  /dev/sdb5       2.5G  3.9M  2.3G   1% /media/ubuntu/99b89b3c-5035-4a32-bf5a-514640fc7493  /dev/sdb1        11G   53M   11G   1% /media/ubuntu/usbdata  NAME   FSTYPE   LABEL                    UUID                                 MOUNTPOINT  sdb                                                                            â"œâ"€sdb4 iso9660  Ubuntu 16.04.2 LTS amd64 2017-02-15-21-44-13-00               /cdrom  â"œâ"€sdb2                                                                         â"œâ"€sdb5 ext4                              99b89b3c-5035-4a32-bf5a-514640fc7493 /media/ubuntu/99b89b3c-5035-4a32-bf5a  â"œâ"€sdb3 vfat     usbboot                  E2B5-7A49                             â""â"€sdb1 ntfs     usbdata                  25FB337F388A948A                     /media/ubuntu/usbdata  loop0  squashfs                                                               /rofs  sda                                                                            â"œâ"€sda2                                                                         â"œâ"€sda5 swap                              6fa9b4a3-962f-4677-8055-e5192e2f1fb3 [SWAP]  â""â"€sda1 ext4                              7edab5f8-81d1-45c8-93de-cf3dfe74d152  cat: hello.txt: No such file or directory  

More information:

mkusb -v

mkusb-dus:   dus 12.2.2  mkusb-11:  mkusb 11.2.1  mkusb-nox: mkusb-nox 11.1.9  mkusb-bas: mkusb version 7.4.2  

I am running it on my laptop that have Ubuntu 16.04 -

cat /etc/lsb-release

DISTRIB_ID=Ubuntu  DISTRIB_RELEASE=16.04  DISTRIB_CODENAME=xenial  DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"  

I run the following:

sudo add-apt-repository universe  sudo add-apt-repository ppa:mkusb/ppa  sudo apt-get update  sudo apt-get install mkusb  sudo -H mkusb  

This is the initial output:

Usage: mkusb [input-file]      # optional parameter  ---------------------------------------------------------------------  d:  dus , guidus, mkusb-dus    - New, easy to use  e: Eleven, sudo -H mkusb-11    - Classic user interface  n: NoX,    sudo mkusb-nox      - original text mode  b: Bas,    sudo mkusb-bas      - basic text mode for old/basic linux  q: Quit  ---------------------------------------------------------------------  Select version of mkusb (d/e/n/b/q)   

And during the installation I believe I chose msdos and to use 20%.


Solution:1

Beginning to debug your problem

  • In the output of df -h the line for aufs should match that of /dev/sdb5

    aufs            3.8G   35M  3.8G   1% /  /dev/sdb5       2.5G  3.9M  2.3G   1% /media/ubuntu/99b89b3c-5035-4a32-bf5a-514640fc7493  

    but the sizes are different. This indicates, that persistence does not work.

  • The partition /dev/sdb5 should be labeled 'casper-rw', but no label is found by lsblk -f

    NAME   FSTYPE  LABEL             UUID                                 MOUNTPOINT  ...  â"œâ"€sdb5 ext4                      99b89b3c-5035-4a32-bf5a-514640fc7493 /media/ubu  

    I am surprised, that there is no label on this partition. Maybe this is the only reason why persistence does not work. Boot live-only. First check that the target partition is the correct one, /dev/sdb5. Then you can try with the following commands,

    sudo umount /dev/sdb5  sudo tune2fs -L casper-rw /dev/sdb5  

    reboot and try again, if there is persistence.

A working persistent live system

It looks like this in a working persistent live system with the default settings (in my Sandisk Extreme 16 GB pendrive)

ubuntu@ubuntu:~$ df -h  Filesystem      Size  Used Avail Use% Mounted on  udev            1.9G     0  1.9G   0% /dev  tmpfs           384M  6.4M  378M   2% /run  /dev/sdb4       1.5G  1.5G     0 100% /cdrom  /dev/loop0      1.4G  1.4G     0 100% /rofs  aufs            6.6G   21M  6.2G   1% /  tmpfs           1.9G  172K  1.9G   1% /dev/shm  tmpfs           5.0M  4.0K  5.0M   1% /run/lock  tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup  tmpfs           1.9G  4.0K  1.9G   1% /tmp  tmpfs           384M   72K  384M   1% /run/user/999  /dev/sdb5       6.6G   21M  6.2G   1% /media/ubuntu/casper-rw  /dev/sdb1       6.7G   35M  6.6G   1% /media/ubuntu/usbdata  ubuntu@ubuntu:~$ lsblk -f  NAME   FSTYPE   LABEL                    UUID                                 MOUNTPOINT  sdb                                                                             â"œâ"€sdb4 iso9660  Ubuntu 16.04.2 LTS amd64 2017-02-15-21-44-13-00               /cdrom  â"œâ"€sdb2                                                                          â"œâ"€sdb5 ext4     casper-rw                713e6d96-24fe-443e-adf8-25d9212e5d33 /media/ubuntu/casper-rw  â"œâ"€sdb3 vfat     usbboot                  CC21-48C5                              â""â"€sdb1 ntfs     usbdata                  0514A98E7CA45722                     /media/ubuntu/usbdata  loop0  squashfs                                                               /rofs  sda                                                                             â"œâ"€sda4 swap                              b69324e1-cab0-459c-97f3-bb42926ee94e [SWAP]  â"œâ"€sda2                                                                          â"œâ"€sda3 ext4     root                     864c54c6-961a-4ad9-8c23-35eb8e0f24fb   â""â"€sda1 vfat     EFI                      274B-0C82                              ubuntu@ubuntu:~$ lsblk -m  NAME     SIZE OWNER GROUP MODE  sdb     14.9G root  disk  brw-rw----  â"œâ"€sdb4   1.5G root  disk  brw-rw----  â"œâ"€sdb2     1M root  disk  brw-rw----  â"œâ"€sdb5   6.6G root  disk  brw-rw----  â"œâ"€sdb3   244M root  disk  brw-rw----  â""â"€sdb1   6.6G root  disk  brw-rw----  loop0    1.4G root  disk  brw-rw----  sda    232.9G root  disk  brw-rw----  â"œâ"€sda4     5G root  disk  brw-rw----  â"œâ"€sda2     1M root  disk  brw-rw----  â"œâ"€sda3   100G root  disk  brw-rw----  â""â"€sda1   300M root  disk  brw-rw----  ubuntu@ubuntu:~$   


Solution:2

I don't know mkusb or what it's trying to do but I wanna give you some advices.

Try this options too:

First, the simplest way, create a live cd or dvd (preferably) installation and try to create a new user (other than the ubuntu user), I have understood that work but I never tried honestly.
Advantage:
· you will be logged in 5 seconds.
Disadvantages: · you could not install updates because your system will crash for incompatibilities when trying to create new images.. update kernel.. or something like that, I really don't know and not remember also.
· keep reading..

Another way is trying to install directly in the usb-stick, but you should keep this in mind:
· Do your usb-stick act as an SDD? so you have to consider things like noatime, nodiratime and stuffs like that (Info for debian)

My best advice would be this: did you tried to install on the usb-stick but it fail? well, do not try reinstall again... instead, try to recover your usb-stick to normal state (format compatible, full capacity, etc), then try again. I've had bad experiences last week related to performance and "Unable to format USB drive with Disks (udisks-error-quark, 0)" In fact I'm just trying to get some reputation to answer HOW TO RECOVER your usb from that -.-

I'm not reply to mkusb, neither giving a solution.. I know that, but if you're loosing a lot of time installing at 2nd time think about this


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »