Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 17977  / 1 Year ago, thu, december 22, 2022, 5:56:48

I am running Ubuntu 20.04 on an embedded device. I will like to ask how to force automatic fsck on bootup? In older Ubuntu versions, this can be achieved by editing the /etc/default/rcS and setting FSCKFIX=yes. However, I read that in newer Ubuntu, this file is not used anymore. So what will be the way to enable automatic fsck on bootup for newer Ubuntu?


More From » boot

 Answers
1

If you want to force fsck with each reboot, there are few steps you need to follow.



  1. use blkid to identify the uuid for the partition.


amarcus@amarcus-desktop:~$ blkid
/dev/mapper/vgubuntu-swap_1: UUID="d24b0766-c9be-49ef-9022-8ccae4f79801" TYPE="swap"
/dev/mapper/vgubuntu-root: UUID="d414c4f9-da0d-42bf-8290-4bcb55b8d984" BLOCK_SIZE="4096" TYPE="ext4"
amarcus@amarcus-desktop:~$



  1. Use uuid or mount point to locate the partition in /etc/fstab


amarcus@amarcus-desktop:~$ cat /etc/fstab 
# /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>
/dev/mapper/vgubuntu-root / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=0AE0-795B /boot/efi vfat umask=0077 0 1
/dev/mapper/vgubuntu-swap_1 none swap sw 0 0

UUID=D41C-2F17 /mnt/WDElements auto umask=0022,gid=1000,uid=1000,x-gvfs-show 0 0


The last column that is a column 6, aka fsck PASS column is used by fsck to determine whether fsck should check filesystem before it is mounted and in which order given partitions in /etc/fstab should be checked


For root partitions, make sure that entry is set to 1



  1. Finally, set the mount counter for that partition to 1.


root@amarcus-desktop:~# tune2fs -c 1 /dev/mapper/vgubuntu-root


Explanation:


Basically, in step 1 you are identifying which partition you want to check at boot.


In step 2, you are making sure that it takes higher priory. It's useful if you are checking more than one partitions. It decide which should be taken up first, then second and so on.


In step 3, you are saying after how many mounts the partition should be checked. The argument 1 specifies that after one mount the partition should be checked. So basically it checks after each mount, i.e. after every restart.


[#1332] Thursday, December 22, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
atereress

Total Points: 79
Total Questions: 106
Total Answers: 119

Location: Federated States of Micronesia
Member since Sun, May 16, 2021
3 Years ago
atereress questions
Wed, Aug 4, 21, 03:15, 3 Years ago
Sat, Apr 16, 22, 17:34, 2 Years ago
Sun, May 15, 22, 15:59, 2 Years ago
;