You are not logged in.

#1 2021-03-03 14:43:57

beroal
Member
From: Ukraine
Registered: 2009-06-07
Posts: 325
Website

strange `umount` error with `ash`

I am writing my hook for `initcpio` (`initramfs`). As I see, the scripts in `initramfs` are executed by the `ash` shell. While testing my scripts on a booted ArchLinux, I stumbled upon a strange difference between `ash` and `bash`.

test2
#!/usr/bin/ash
DEV=/dev/disk/by-partlabel/TEST
mount "$DEV" /root/mnt/temp
umount "$DEV"

Executing the above script outputs

root@>./test2
[37511.101479] F2FS-fs (sda5): Can't find valid F2FS filesystem in 1th superblock
[37511.103303] F2FS-fs (sda5): Can't find valid F2FS filesystem in 2th superblock
umount: can't unmount /dev/disk/by-partlabel/TEST: Invalid argument

I suppose that the F2FS messages are from the kernel. Nevertheless, the partition gets mounted. It does not get unmounted.

If I replace `ash` with `bash`, I see no error. I don't understand what is wrong with my command and why replacing `ash` with `bash` fixes the error. Obviously, I can't use `bash` in a real `initramfs`.

ls -l -d /root/mnt/temp
drwxr-xr-x 2 root root 4096 Apr 28  2016 /root/mnt/temp
ls -l /dev/disk/by-partlabel/TEST
lrwxrwxrwx 1 root root 10 Mar  3 14:46 /dev/disk/by-partlabel/TEST -> ../../sda5

we are not condemned to write ugly code

Offline

#2 2021-03-16 12:07:33

ponyrider
Member
Registered: 2014-11-18
Posts: 112

Re: strange `umount` error with `ash`

umount /root/mnt/temp

Offline

#3 2021-03-16 13:21:03

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: strange `umount` error with `ash`

ash is busybox, "mount" and "umount" are built-ins, not /usr/bin/u|mount - try the full paths.

Offline

Board footer

Powered by FluxBB