Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Q] Splitting / to different partitions & using crontab
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
GummyGum173
n00b
n00b


Joined: 09 Apr 2014
Posts: 50

PostPosted: Tue Aug 12, 2014 6:27 pm    Post subject: [Q] Splitting / to different partitions & using crontab Reply with quote

Hello, newbie here.

I've heard that splitting your / to different partitions (i.e. a partition for /home, /tmp etc) is much better & much secure, yet, I've seen 0 guides about it in the wiki or in the forums, so can someone please guide me on spliting the system to different partitions after the installation?

Using openRC & genkernel 3.14.14 if it makes any difference.


Also, is there a default crontab tool installed in Gentoo? If not, what tool would you recommend? I only need it for a few simple tasks, nothing big.


P.S. Is there a more recent "Flying with Gentoo" guide? (Talking about this: https://forums.gentoo.org/viewtopic-t-231170-start-0.html).
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3171

PostPosted: Tue Aug 12, 2014 7:11 pm    Post subject: Reply with quote

Hello Newbie
you better pick another distro. Just like you would learn climbing small walls first before going for Mount Everest. Ok, Gentoo is not impossible, but there is a price. A price newbies pay in pain. You have been warned.

Anyway, partitioning:
Check how much RAM you have. Do you want to use hiberation? Will you do any tasks that require insane amounts of memory?
If you have less memory than you're going to need, you must make up for it with SWAP partition. Also, if you want to ever use hibernate to disk, you MUST have swap partition. RAM usage on my pc hardly ever exeeds 1 GB - obviously it goes up when I run several VMs :) but that's not a typical use case.
So, it's usualy a good idea to get 512MB-1GB SWAP. You would most likely know if you needed more.
The rest: for gentoo you're going to need 15-30GB for system. Bigger / will buy you more time to learn how to reclaim some space and give you extra flexibility Oh, and will let you build openoffice :D
It's common to have separate /home, as it keeps your data relatively safe when you grow tired and decide to install Ubuntu instead ;-)
Also, some common setups takes advantage of separate /boot. You probably don't need it. Probably. Dont bother with spliting / into more pieces. If you needed separate /usr, you would know that.

OpenRC and genkernel make absolutely no difference on partitioning.

Also, ANY cron will do. Feel free to roll a die. You can also roll a die for your pick on logger. All those in repo are good enough.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54387
Location: 56N 3W

PostPosted: Tue Aug 12, 2014 7:34 pm    Post subject: Reply with quote

GummyGum173,

There is a danger of starting a flamewar in my response, so I will skip the history.

/home should be it own partition. That way writes by users are confined here.
/tmp can be tmpfs (RAM) if you have the RAM for it.
/usr can be its own filesysem. It can be mounted read only except for updates, if you are paranoid.
/var can be its own filesystem.
/opt and /usr/local can be on their own partitions too but gentoo makes little use of these.

Some portage specific things ...
/usr/portage contains many small files but it will fit into 1G given a 1k block size
/usr/portage/distfiles contains large files, so there is scope for tuning here
/usr/portage/packages is similar.

This gets you something like
Code:
$ df
Filesystem                1K-blocks      Used Available Use% Mounted on
/dev/dm-0                   1998672    720224   1157208  39% /
/dev/dm-1                  61796348  14507312  44126924  25% /usr
/dev/dm-2                  61796348   5570492  53063744  10% /var
tmpfs                       1641404      1320   1640084   1% /run
udev                          10240         0     10240   0% /dev
shm                         8207004         0   8207004   0% /dev/shm
cgroup_root                   10240         0     10240   0% /sys/fs/cgroup
/dev/mapper/vg-home      1056763060 826925600 176133988  83% /home
/dev/mapper/ssd-opt         1998672    244284   1633148  14% /opt
/dev/shm                    8207004        48   8206956   1% /tmp
/dev/mapper/vg-var         60764220  33744448  23910756  59% /mnt/oldvar
/dev/mapper/ssd-local       1998672      5232   1872200   1% /usr/local
/dev/mapper/vg-portage      2046355    433118   1508380  23% /usr/portage
/dev/mapper/vg-distfiles   92760056  69651372  18689356  79% /usr/portage/distfiles
/dev/mapper/vg-packages    61796348  48431460  10203160  83% /usr/portage/packages
/dev/shm                    8207004     27452   8179552   1% /var/tmp/portage
Its all lvm on top of raid5 but you can mostly ignore that.
The downside to lots of partitions is that its not easy to move free space around. LVM addresses that.

How to do it ...
Boot with a liveCD, make a partition for home, make a filesystem on /home
mount your gentoo an /mnt/gentoo but make it read only to avoid accidents
mount your new home, on say /mnt/cdrom
cp -a /mnt/gentoo/home/* /mnt/cdrom/
unmount /mnt/cdrom/
remount /mnt/gentoo/ as rw
edit /etc/fstab by adding an entry for /home
touch /mnt/gentoo/home/oldhome
reboot normally to test.

ls /home/oldhome should return a file not found error.

At this point you have two copies of /home one mounted over the other.
The file /home/oldhome only exists on the old home.

When you are happy it works, you can reboot with the liveCD and remove your old howe, if you need to recover the space.
The others are similar. /usr and /var are harder as they need to be mounted before udev starts. However, genkernel will build you an initrd to do that.

If you are paranoid enough to go with the above, you should be restricting what each filesystem supports too.
e.g. noexec,nosuid,nodev on /home stops users running programs from /home. Set User ID binaries won't and no device nodes can be created there
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
GummyGum173
n00b
n00b


Joined: 09 Apr 2014
Posts: 50

PostPosted: Tue Aug 12, 2014 7:49 pm    Post subject: Reply with quote

szatox wrote:
Hello Newbie
you better pick another distro. Just like you would learn climbing small walls first before going for Mount Everest. Ok, Gentoo is not impossible, but there is a price. A price newbies pay in pain. You have been warned.

Anyway, partitioning:
Check how much RAM you have. Do you want to use hiberation? Will you do any tasks that require insane amounts of memory?
If you have less memory than you're going to need, you must make up for it with SWAP partition. Also, if you want to ever use hibernate to disk, you MUST have swap partition. RAM usage on my pc hardly ever exeeds 1 GB - obviously it goes up when I run several VMs :) but that's not a typical use case.
So, it's usualy a good idea to get 512MB-1GB SWAP. You would most likely know if you needed more.
The rest: for gentoo you're going to need 15-30GB for system. Bigger / will buy you more time to learn how to reclaim some space and give you extra flexibility Oh, and will let you build openoffice :D
It's common to have separate /home, as it keeps your data relatively safe when you grow tired and decide to install Ubuntu instead ;-)
Also, some common setups takes advantage of separate /boot. You probably don't need it. Probably. Dont bother with spliting / into more pieces. If you needed separate /usr, you would know that.

OpenRC and genkernel make absolutely no difference on partitioning.

Also, ANY cron will do. Feel free to roll a die. You can also roll a die for your pick on logger. All those in repo are good enough.


You didn't really get me, I meant splitting the partitions like Neddy stated below, I'm kind off familiar with Linux & have Gentoo installed for about 2 months, but I only learn whenever I fail, and after a brief read in the interwebs I understood that if you split / to different partitions you get generally less chances to f**k up something (as you would only need to rewrite, /usr for example if you messed something there, or if suddenly the PC fails when it reads\writes from /tmp then the whole partition won't corrupt).

And thanks for the cron advice :)

NeddySeagoon wrote:
GummyGum173,

There is a danger of starting a flamewar in my response, so I will skip the history.

/home should be it own partition. That way writes by users are confined here.
/tmp can be tmpfs (RAM) if you have the RAM for it.
/usr can be its own filesysem. It can be mounted read only except for updates, if you are paranoid.
/var can be its own filesystem.
/opt and /usr/local can be on their own partitions too but gentoo makes little use of these.

Some portage specific things ...
/usr/portage contains many small files but it will fit into 1G given a 1k block size
/usr/portage/distfiles contains large files, so there is scope for tuning here
/usr/portage/packages is similar.

This gets you something like
Code:
$ df
Filesystem                1K-blocks      Used Available Use% Mounted on
/dev/dm-0                   1998672    720224   1157208  39% /
/dev/dm-1                  61796348  14507312  44126924  25% /usr
/dev/dm-2                  61796348   5570492  53063744  10% /var
tmpfs                       1641404      1320   1640084   1% /run
udev                          10240         0     10240   0% /dev
shm                         8207004         0   8207004   0% /dev/shm
cgroup_root                   10240         0     10240   0% /sys/fs/cgroup
/dev/mapper/vg-home      1056763060 826925600 176133988  83% /home
/dev/mapper/ssd-opt         1998672    244284   1633148  14% /opt
/dev/shm                    8207004        48   8206956   1% /tmp
/dev/mapper/vg-var         60764220  33744448  23910756  59% /mnt/oldvar
/dev/mapper/ssd-local       1998672      5232   1872200   1% /usr/local
/dev/mapper/vg-portage      2046355    433118   1508380  23% /usr/portage
/dev/mapper/vg-distfiles   92760056  69651372  18689356  79% /usr/portage/distfiles
/dev/mapper/vg-packages    61796348  48431460  10203160  83% /usr/portage/packages
/dev/shm                    8207004     27452   8179552   1% /var/tmp/portage
Its all lvm on top of raid5 but you can mostly ignore that.
The downside to lots of partitions is that its not easy to move free space around. LVM addresses that.

How to do it ...
Boot with a liveCD, make a partition for home, make a filesystem on /home
mount your gentoo an /mnt/gentoo but make it read only to avoid accidents
mount your new home, on say /mnt/cdrom
cp -a /mnt/gentoo/home/* /mnt/cdrom/
unmount /mnt/cdrom/
remount /mnt/gentoo/ as rw
edit /etc/fstab by adding an entry for /home
touch /mnt/gentoo/home/oldhome
reboot normally to test.

ls /home/oldhome should return a file not found error.

At this point you have two copies of /home one mounted over the other.
The file /home/oldhome only exists on the old home.

When you are happy it works, you can reboot with the liveCD and remove your old howe, if you need to recover the space.
The others are similar. /usr and /var are harder as they need to be mounted before udev starts. However, genkernel will build you an initrd to do that.

If you are paranoid enough to go with the above, you should be restricting what each filesystem supports too.
e.g. noexec,nosuid,nodev on /home stops users running programs from /home. Set User ID binaries won't and no device nodes can be created there



Ok, thanks a bunch, will try that and come & report my success here, if there will be any problem :)
Back to top
View user's profile Send private message
gentoo_ram
Guru
Guru


Joined: 25 Oct 2007
Posts: 476
Location: San Diego, California USA

PostPosted: Fri Aug 15, 2014 12:01 am    Post subject: Reply with quote

There are lots of ways to partition for various reasons. I mostly have my partitions split by security settings. Here are mine:

Code:
Filesystem                 Size  Used Avail Use% Mounted on
/dev/md12                  3.7G  1.5G  2.1G  42% /
/dev/mapper/vg-usr          50G   21G   27G  44% /usr
/dev/mapper/vg-opt         5.8G  2.8G  2.7G  51% /opt
/dev/mapper/vg-home        148G   78G   63G  56% /home
/dev/mapper/vg-tmp         5.8G   13M  5.5G   1% /tmp
/dev/mapper/vg-vtmp         12G  511M   11G   5% /var/tmp
/dev/mapper/vg-log          16G  2.0G   13G  14% /var/log


(plus others for media storage...)

I keep all logs (syslog) on /var/log. I keep logs on a separate partition so they won't end up filling up some other partition. I set the filesystem flags: (rw,noatime,nosuid,noexec,nodev) Notice these flags are pretty tight.

/tmp and /var/tmp I put on separate partitions. /var/tmp is used for portage builds. /tmp is used for other stuff. Flags are : (rw,noatime,nosuid,nodev,commit=0) Can't have noexec on these since some build scripts need to execute stuff made in intermediate steps. Security is a little lighter.

/opt is for 'external' software usually installed outside of portage for me. Flags: (rw,noatime)

/home is for user files. Flags: (rw,noatime,nodev,nosuid)

The partition sizes are totally up to you.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum