Move /var directory to a new partition

skp18

New Member
Joined
Dec 4, 2022
Messages
15
Reaction score
1
Credits
139
I'd like to move /var directory to a new partition on the SAME disk. I'm not adding any new hard disk.
I tried the following commands to do so. Can someone help with the last 2 commands? Also, how do I make sure it doesn't use old /var anymore?

lsblk
mkdir /mnt/newvar
blkid
mount /dev/xvda1 /mnt/newvar
df -h /mnt/newvar/
rsync -aqxP /var/* /mnt/newvar/

umount /mnt/newvar/ /mnt/var/
the above command throws no mount point specified.

vi /etc/fstab
how to add the new partition in fstab?
 


KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,686
Reaction score
9,179
Credits
88,714
I'm not really sure, as I've never done it. Someone here will likely know - and will hopefully share.

On some forums they'd likely just tell you to not do that, 'cause /var is maybe a few GB in size, and then not actually help you. Here, I'm sure someone'll help you *if* they know how. This sounds like something @f33dm3bits would know, actually.

But, I do wanna know what your motivation is. Why would you want to put /var on its own partition?
 
OP
S

skp18

New Member
Joined
Dec 4, 2022
Messages
15
Reaction score
1
Credits
139
Why would you want to put /var on its own partition? The disk size is 200GB. I have 150 GB of free space. I can set 50GB for /var. Moreover, it's a requirement that I have to create a new partition.
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,686
Reaction score
9,179
Credits
88,714
Moreover, it's a requirement that I have to create a new partition.

Ah, this is schoolwork?

We *help* with schoolwork but seldom give exact instructions, 'cause... Well, you know... It's schoolwork and folks should be learning.

Don't worry, I'm not slagging on you or anything, it's cool to ask questions when you need help.
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
6,414
Reaction score
4,873
Credits
47,133
Why would you want to put /var on its own partition? The disk size is 200GB. I have 150 GB of free space. I can set 50GB for /var. Moreover, it's a requirement that I have to create a new partition.
On a desktop system putting /var on it's own partition isn't going to give you any advantage on a server it will in case some log files or directories grow during the night when you are away and the /var filesystem runs out of disk-space. You will have to do it during live boot when no changes are being made my the system, otherwise there might be a chance that some file can get corrupted when syncing the files from the old to the new partition. For fstab just name of the volume or partition mount location filesystem option, just have a look at /etc/fstab as to see what / looks like.
 

sphen

Well-Known Member
Joined
Dec 12, 2022
Messages
868
Reaction score
751
Credits
10,394
Ah, this is schoolwork?

We *help* with schoolwork but seldom give exact instructions, 'cause... Well, you know... It's schoolwork and folks should be learning.

Don't worry, I'm not slagging on you or anything, it's cool to ask questions when you need help.
Maybe, but how many people do schoolwork on Christmas Eve?

If it is schoolwork, the teacher could be one of the members here, watching for new threads. Hey, they could be me. ;-)

I agree, it is cool to ask questions.
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
10,686
Reaction score
9,179
Credits
88,714
Maybe, but how many people do schoolwork on Christmas Eve?

Those who are behind on their work, 'cause they're stuck figuring out how to move /var to its own partition?

I used to do schoolwork pretty much any day of the year. In a way, I kinda miss it.
 

forester

Well-Known Member
Joined
Mar 5, 2022
Messages
544
Reaction score
317
Credits
3,829
Use gparted to first shrink your /home by 4-5GB. Add a partition of same size and format it.

edit you etc/fstab file to depict changes made.

NOTE: some prefer a non-journaling file system for /var
 

MikeWalsh

Well-Known Member
Joined
Aug 29, 2022
Messages
607
Reaction score
754
Credits
7,961
In Puppy, we'd simply move /var to a new location, delete the old one, then sym-link it back. But most of us run multiple Puppies; we'd do this from a different Puppy, and the moving would all be done manually, by actually digging around in the file-system! (*shock, horror!*) I'd do this in about 2 minutes, tops.....without even thinking about it.

Not exactly relevant here, I suspect. Hell. We're highly "unorthodox" in Puppy-land..... :D

(*shrug*)

Mike. :p
 

forester

Well-Known Member
Joined
Mar 5, 2022
Messages
544
Reaction score
317
Credits
3,829
We're highly "unorthodox" in Puppy-land.....
I never fell under the bell curve, anyways! Long Live Puppy!

Happy New Year!
 

Members online


Top