Ubuntu16.04 ext4 format Hard disk mount normal user permission control operation method
- 2020-11-20 06:20:58
- OfStack
Use cases
Due to history, my Ubuntu system is short of space, so I want to mount an ext4 partition (/dev/sda12) of my computer's internal hard drive to the system automatically in a way that users can read and write. My user name is totoro.
operation
Boot auto mount hard disk: as described in the blog, add the last line of the /etc/fstab file
"UUID=XXX-XX /media/totoro/KylinData ext4 defaults 0 2"1
Mount the partition specified for UUID to /media/totoro/KylinData.
The first parameter, UUID, is recommended because there are only 11 UUID per partition; Using /dev/sdaN is also possible, but the partition number of 1 partition N will change with the change of the hard disk partition, so it is not recommended to write so. The console command for UUID obtained from /dev/sdaN is "sudo blkid(or lsblk-ES34en)".
However, this is mounted in root mode to change the user and group where the hard disk resides to the current user:
sudo chown -R totoro:totoro /media/totoro/KylinData/
sudo umount /media/totoro/KylinData
When restarted, it is automatically mounted for the current user (not root)
conclusion