You are not logged in.

#1 2017-12-02 20:13:15

sapphous
Member
Registered: 2017-12-02
Posts: 2

Moving /usr To Folder On Different Partition

Greetings Archfolk,

My root partition is 19GB, which as it turns out is not big enough for my needs; I've only got about 500mb left. 11GB of this is my /usr partition, so I'd really like to move that (/var, /etc, and /home are small, my pacman cache is already on another partition). Ideally I would reconfigure my entire system setup and install from scratch, but the real constraint is Windows needing a lot of space on my SSD, so until I get a new one I'm not going to do that; I want to move /usr off of the SSD and onto the HDD I use for data.

My setup does not have /home on a separate partition; instead, I have /oikos mapped to a large data partition, and /home mostly contains symlinks to things on /oikos. Now I would like to move /usr to a directory on /oikos. That is the curve ball; the instructions I can find (such as here: https://bbs.archlinux.org/viewtopic.php?id=189520) are all for mapping /usr to its OWN partition. Thus if I put the line

/oikos/usr     /usr     none     bind    0    0

into /etc/fstab and follow the instructions otherwise, I am concerned that the mkinitcpio usr hook will fail to mount /usr (because it requires /oikos to be mounted first). I have not messed with mkinitcpio before so I don't have an understanding of how exactly it works; consequently I'm not sure what to do. /oikos is ext4, so linux permissions and everything else are supported just fine.

Would somebody mind helping me out?

Thanks,
sapphous

Last edited by sapphous (2017-12-02 20:14:13)

Offline

#2 2017-12-02 20:49:15

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Moving /usr To Folder On Different Partition

My guess is you'll need to make a custom hook of sorts. I have never done such a thing. I would start with the man page mkinitcpio(8).

Welcome to the forums. smile


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#3 2017-12-02 21:00:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Moving /usr To Folder On Different Partition

sapphous wrote:

My root partition is 19GB, which as it turns out is not big enough for my needs; I've only got about 500mb left. 11GB of this is my /usr partition...

Hold on, something is really off here.

It's pretty hard to use up 19G on a root partition, so this in itself had me suspicious that there was some problem hiding here: you're better off fixing the problem than doing something tricky that may only postpone the inevitable.  While it may be possible to use 19G if you have every single big DE installed and nearly every single package in the repos, I just don't think that is likely.

But then you say only 11G of this is in /usr.  That's even more odd.  Sure 11G is more practical to use up from installed packages (that's still quite a lot - a couple big DEs and a bunch of huge packages perhaps would do it).  But this means 8G of your root partition are used up outside of /usr.  That is definitely a symptom of a problem.

What is taking up this space?  Are logs growing out of control under /var?  If so, your computer is screaming at you that there is a problem, listen.  Or do you have a single partition for / and /home so that data in your home directory is using up 8G?  If that is the case moving /home is easier and better than moving /usr.

Edit: I missed that part of your post, you don't have a home partition.  And while you claim that most of what is in home is symlinks, that seems like it may not be the case.  In any event, first figure out what is actually using up space first.

Last edited by Trilby (2017-12-02 21:01:57)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2017-12-02 21:02:02

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Moving /usr To Folder On Different Partition

I agree with Trilby.

Use ncdu to see what is taking up all of this space.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#5 2017-12-02 21:08:12

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: Moving /usr To Folder On Different Partition

Agree to check out ncdu or similar to find out where space is actually being used (especially for non /usr), but my laptop currently has 19GB used in /usr....10 GB of that is just Matlab, to be fair. My other laptop had like 3 GB or something taken up for TeX related data, so depending what you have installed it can grow fairly large.

I'd wager it being an issue with ~/.cache or ~/.log though.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#6 2017-12-02 21:45:27

sapphous
Member
Registered: 2017-12-02
Posts: 2

Re: Moving /usr To Folder On Different Partition

It is possible for me to reclaim a bit of space without moving /usr, but I'm concerned that I'll only be postponing the issue. My root partition's memory usage:

/opt, /etc, /srv, /mnt: less than 500mb total
/home: ~2gb (over half in .cache, most of which is yarn and mozilla; I should have clarified, my data folders are all symlinks, as is .local, but most app configuration data is still on the root partition)
/var: ~1.5gb (pretty much all in log)
/usr: ~11gb (5.5 fairly well-distributed within lib, 4 within share)

While looking at /var I realized that 1.5gb were still in the pacman cache folder, although I'd reconfigured pacman to use a folder on a different partition; so I cleaned that out and now have 2gb rather than 0.5gb free. I can probably recover the space used by /home and by /var/log as well, which would altogether put me up to 5 point something gb free. So you're right about ~/.cache and about /var/log; my /var/log/journal directory is taking up 1.4gb, so I'll fix that tongue. Thanks!

That will solve my immediate problem--can't believe I didn't clean out the old pacman log directory! I would still like to know how to move /usr for future reference if anyone knows though.

Last edited by sapphous (2017-12-02 21:49:59)

Offline

#7 2017-12-02 22:05:49

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Moving /usr To Folder On Different Partition

Although it is possible, /var is the most difficult to split onto its own partition. It would much easier to move /home instead.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#8 2017-12-02 22:45:49

Monkey_Mod
Member
Registered: 2017-12-02
Posts: 9

Re: Moving /usr To Folder On Different Partition

Boot a live Arch Linux environment and mount all partitions:

mount /dev/sdXY /mnt
mount /dev/sdXY (oikos) /mnt/oikos
mount /dev/sdXY (home) /mnt/home
mount whatever else you need to to /mnt/partition

then chroot:

arch-chroot /mnt

Edit /etc/mkinitcpio.conf:
##   NOTE: If you have /usr on a separate partition, you MUST include the
#    usr, fsck and shutdown hooks.
# HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)
HOOKS=(base udev autodetect modconf block filesystems keyboard usr fsck shutdown)

Edit /etc/fstab:
/dev/sdYX        /usr      ext4          rw,relatime,data=ordered    0 0

Point your /oikos partition in dev/sdYX
I'm not sure what options would be proper, data=ordered may be in the defaults
If not using the systemd hook, add the usr hook (which we did above). This will mount the /usr partition after root is mounted.
So the hook may not be needed if you edit the /etc/fstab file without the hook.
I can look into how to order the partitions to mount /oikos after root. Possibly with a passno of 1? I'm not sure. The passno will be the second number instead of 0 0, change to 0 1 which is how root is then boot and following passno for other partitions are 0 2. Maybe 0 0 will be okay, you'll have to test to see what works, if anything and if it doesn't you can always reboot into the Arch live environment and change things back to how they were. I usually test things to see what works by trail and error.

Regenerate mkinitcpio changes for the hooks:

sudo mkinitcpio -p linux && reboot

I quickly searched to resolve this, I hope it helps. Let us know if you get it working, if not; I'll read instead of skimming the pages. :-)
I need to see how to get /oikos mounted after root and before it tries to mount /usr unless since /usr is in the fstab how it is, maybe it will work.

Last edited by Monkey_Mod (2017-12-03 00:18:10)

Offline

#9 2017-12-02 23:02:42

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: Moving /usr To Folder On Different Partition

@Monkey_Mod passno only controls if the filesystem should be checked by fsck and the order of those checks.
There is no /home partition and /oikos is an already exiting filesystem mounting the same block device to /usr as well is probably not what you intended or sapphous desires.

Offline

#10 2017-12-02 23:19:02

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Moving /usr To Folder On Different Partition

Monkey_Mod, please use code tags for stuff that would be in a terminal. Thanks.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#11 2017-12-02 23:54:57

Monkey_Mod
Member
Registered: 2017-12-02
Posts: 9

Re: Moving /usr To Folder On Different Partition

loqs wrote:

@Monkey_Mod passno only controls if the filesystem should be checked by fsck and the order of those checks.
There is no /home partition and /oikos is an already exiting filesystem mounting the same block device to /usr as well is probably not what you intended or sapphous desires.

Right, Just something I thought of by skimming pages of the wiki. Thanks for clarifying the passno, I learned something new today.

fsckd wrote:

Monkey_Mod, please use code tags for stuff that would be in a terminal. Thanks.

Sorry I'll look up how to do that, I've never used a forum before.

Offline

#12 2017-12-03 00:01:01

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Moving /usr To Folder On Different Partition

Monkey_Mod wrote:
fsckd wrote:

Monkey_Mod, please use code tags for stuff that would be in a terminal. Thanks.

Sorry I'll look up how to do that, I've never used a forum before.

Ahh, sorry, at the bottom of the page, next to the post entry text box, is a link called BBCode. That will describe how.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#13 2017-12-03 01:02:07

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: Moving /usr To Folder On Different Partition

/var on my machine is already 8G. On my previous install, I found 15G rather too little. Is this really so odd? The vast majority is in cache. (1.1G roughly for logs.) Admittedly, if I took pacman's cache out of it, it would reduce by over 6G. But, still, it is apparently relatively straightforward to fill /var ....


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#14 2017-12-03 01:05:56

Monkey_Mod
Member
Registered: 2017-12-02
Posts: 9

Re: Moving /usr To Folder On Different Partition

sapphous wrote:

Greetings Archfolk,

My root partition is 19GB, which as it turns out is not big enough for my needs; I've only got about 500mb left. 11GB of this is my /usr partition, so I'd really like to move that (/var, /etc, and /home are small, my pacman cache is already on another partition). Ideally I would reconfigure my entire system setup and install from scratch, but the real constraint is Windows needing a lot of space on my SSD, so until I get a new one I'm not going to do that; I want to move /usr off of the SSD and onto the HDD I use for data.

My setup does not have /home on a separate partition; instead, I have /oikos mapped to a large data partition, and /home mostly contains symlinks to things on /oikos. Now I would like to move /usr to a directory on /oikos. That is the curve ball; the instructions I can find (such as here: https://bbs.archlinux.org/viewtopic.php?id=189520) are all for mapping /usr to its OWN partition. Thus if I put the line

/oikos/usr     /usr     none     bind    0    0

into /etc/fstab and follow the instructions otherwise, I am concerned that the mkinitcpio usr hook will fail to mount /usr (because it requires /oikos to be mounted first). I have not messed with mkinitcpio before so I don't have an understanding of how exactly it works; consequently I'm not sure what to do. /oikos is ext4, so linux permissions and everything else are supported just fine.

Would somebody mind helping me out?

Thanks,
sapphous

I'd try that method and see, you can always boot a live image and correct what went wrong.
I don't think you can mount a directory to a block device. You can mount a block device to a directory though. I would follow the link you posted above.

Last edited by Monkey_Mod (2017-12-03 02:04:44)

Offline

Board footer

Powered by FluxBB