[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: mount new block deivce in existing dir



On 2023-03-05 at 14:11, Ken Young wrote:

> Hello
> 
> My vps has limited volume for /. You can see it as follows.
> 
> root@nxacloud-bloghost:~# lsb_release -cd
> 
> Description: Debian GNU/Linux 11 (bullseye)
> 
> Codename: bullseye
> 
> 
> root@nxacloud-bloghost:~# df -h
> 
> Filesystem      Size  Used Avail Use% Mounted on
> 
> udev            472M     0  472M   0% /dev
> 
> tmpfs            98M  496K   98M   1% /run
> 
> /dev/vda1       9.7G  1.5G  7.9G  16% /
> ...
> 
> 
> So I want to add a block device /dev/vdb and fdisk/format it and mount it
> as /home dir.
> Since /home already exists (even have data in this path). can I mount it
> without problem?

If you mount the new volume over the existing directory, then attempts
to access that directory will see the contents of the new volume, not
the pre-existing contents of the directory.

I'm not familiar with what constraints being in a VPS environment may
apply to this. In order to achieve what you want, in a non-VPS
environment, you would need to:

* Create and format your new filesystem.

* Log in as a user which does not need the contents of /home in order to
function. (I don't know what the constraints of your VPS are; this can
typically be done by logging in as root, but depending on the system
configuration there might be other factors.)

* Move the contents of /home (but not /home itself!) into a new,
temporary directory.

* Mount the new volume over /home. (And make sure that fstab, etc., are
configured to perform that mount automatically in the future.)

* Move the contents of the temporary directory back into place in /home.

At that point, if everything was done correctly and no special
permissions considerations apply, it should be possible and safe to log
back in as an ordinary user and have things work correctly.

Caveat emptor; this is not a terribly esoteric operation, but if it is
not carried out quite correctly, it is not one entirely without risk.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: