I'm Trying to set my installation of Ubuntu Server 20.04 to automatically mount a USB drive to act as a backup destination. However, I have noticed that when I plug in the USB, Fstab fails and the system won't boot. I'm not sure how to edit Fstab, but I tried running this command:
sudo blkid | grep /dev/sdf1 | sed -e 's/:.* UUID/;UUID/' -e 's/ TYPE.*//' | while read re; do sed -i "s;$re;" /etc/fstab; done
I'm not sure how the file looked before, but this is the fstab now:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/c2713101-d0be-4d04-bab5-30046766b610 / ext4 defaults 0 0
/swap.img none swap sw 0 0
It looks like umask is not a supported option...
Actually it doesn't:
If you want to use
UUID
infstab
this is the correct notation:First make a mountpoint
mkdir /home/yourusername/mydirectory
- whatever/wherever you want to call itInsert your USB
In a terminal type
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,UUID
part of the output should be like something like:
NAME SIZE TYPE FSTYPE MOUNTPOINT UUID
sda 30G disk
├─sda1 977M part swap [SWAP] ba7f8262-edb3-434b-8f08-e1e81314a63d
└─sda2 29G part ext4 / fdfff53a-b236-45c5-bda8-0287c7a494aa
sr0 1024M rom
locate your usb in the output:
With a text editor like gedit or vi or nano, open up /etc/fstab:
in another terminal type
sudo gedit /etc/fstab
at the end of that file add a line
UUID=fdfff53a-b236-45c5-bda8-0287c7a494aa /home/yourusername/mydirectory ext4 defaults 0 0
make sure to use the corresponding UUID and FSTYPE(in my case ext4) of your usb from YOUR output, NOT the one that's indicated above from my output.
save it and exit.
(if your usb is already inserted)in the terminal type
sudo mount -a
you should be able to
cd /home/yourusername/mydirectory
and be in the usb.Check your BIOS boot order.
If one of the partitions on the USB stick has the
boot
flag set, and the BIOS finds it first, the BIOS will try to boot from it. When that fails, there's no fallback.will show if this is the case. Read
man parted sudo
.