On Wed, Feb 08, 2023 at 07:15:27PM +0100, Paul de Weerd wrote:
> On Wed, Feb 08, 2023 at 04:50:32PM +0100, Jan Stary wrote:
> | On Feb 08 13:56:18, [email protected] wrote:
> | > 1) close any open files stored there
> | > 2) make sure no process has the media as $PWD (as in, cd away from there,
> | >    and really a variation on the first)
> | > 3) issue at least one sync command (some folklore will insist on three)
> | > 4) umount the media from wherever it was mounted
> | 
> | 4 takes care of 1,2,3, right?
> 
> Not if the kernel has a file open on it (e.g. a swap file [1]) or if
> there's another mount somewhere in the filesystem you're trying to
> unmount (a special case of the first condition, I guess).
> 
> [weerd@kale] $ doas mount /dev/sd3a /mnt
> [weerd@kale] $ doas mkdir /mnt/deeper
> [weerd@kale] $ doas mount /dev/sd3d /mnt/deeper
> [weerd@kale] $ doas dd if=/dev/zero of=/mnt/swap bs=1M count=4096
> [weerd@kale] $ doas swapon /mnt/swap
> 
> The kernel is not going to let you `umount /mnt`, and forcibly
> removing the device is very likely going to lead to amazing new
> learning opportunities.
> 
> So, yeah, as people have stated .. the way to safely remove a USB
> drive from your system depends on what you were using the USB drive
> for.  For the generic case, where we have no clue what OP was doing:
> shut down your machine first and remove the device then.
> 
Does shut down save you from the case above?
Shut down is the same as umount -f ?

Nola

-- 
Nils Ola Nilsson, 🐞 [email protected]

Reply via email to