# [ANSWERED] ssd laptop question

## xtx

http://en.gentoo-wiki.com/wiki/Solid_State_Disk

that link goes into a lot of detail about what to do with a ssd, but then for laptops simply says "one thing you do want to do though is put /portage in /var/tmp/"

now i'm not sure if i'm being dumb, if this is outdated, or what, but a simple 

```
mv /usr/portage /var/tmp
```

 doesn't work. i even added 

```
portdir="/var/tmp/portage"
```

 in /etc/make.conf but i still was told to revert back to my original settings when i tried to emerge xorg-drivers.

at this point i'm simply emerging xorg-drivers with portage in /usr/portage. how bad is this for my drive? if i continue to emerge things like this will i kill my ssd very quickly?Last edited by xtx on Thu Apr 12, 2012 4:19 pm; edited 1 time in total

----------

## Ant P.

The point is to not have portage on a partition on the SSD since it's full of frequently changing tiny files. It's generally good practice to move /usr/portage and /usr/portage/distfiles to /var anyway since that's what the FHS says it's for; I use /var/db/repositories/gentoo and /var/cache/distfiles on all my machines.

And /var/tmp/portage doesn't make sense since that's the temporary directory used for compiling. Unless you want your portage tree to randomly be deleted...Last edited by Ant P. on Thu Apr 12, 2012 9:59 am; edited 2 times in total

----------

## Telemin

Hi,

That tutorial is mostly written based on the assumption that you have a HDD somewhere as well as your SSD.  In the laptop case, you probably only have the one drive, the SSD.

The tutorial is also badly written, what it essentially means is that you ought to mount both /tmp and /var/tmp as tmpfs ramdisks, but you will have to leave /usr/portage alone as you can't put this on a ramdisk without needing to download the entire repo every time you want to emerge.  For example my /etc/fstab looks like this:

```

/dev/sda1      /boot      ext2      noauto,noatime         1 2

/dev/sda2      /      ext4      noatime            0 1

tmpfs         /tmp      tmpfs      noatime,size=8G      0 0

tmpfs         /var/tmp   tmpfs      noatime,size=8G      0 0

```

Where 8Gb is the total size of my RAM, as by default a tmpfs will only fgo up to 1/2 available memory I think.

And that will take care of the risk of you thrashing your SSD when emerging, although I'd adviose going easy on the emerge --syncs and consider mounting your /var/log to tmpfs as well if you are worried about a lot of log writes.

Beyond that you have essentially optimized as best you can without having a HDD to put /usr/portage etc. on to minimize other writes.

The other thing to consider is mounting your browser cache to a ramdisk, this will both reduce writes and speed up your browser considerably since firefox is certainly IO bound due to the sqlite DB it uses and chrome possibly is too.

HTH

-Telemin-

----------

## robdd

Hi xtx,

I'm not sure how much you know about Unix/Linux, so please don't be offended if I'm telling you how to suck eggs, but..

One of the great things about the Unix/Linux file system is that it's one tree (as opposed to Windoze, which has those ghastly C:, D:, etc drives, and until recently had no links at all). You can split your filesystem over multiple physical partitions, and you can also use soft links to re-position directories anywhere in your filesystem.

Normally the root user has a home directory of /root, and users are in /home/user1, /home/user2, etc. Now I normally configure my systems with a / partition, which holds all the essential boot stuff, and another /usr partition with other operating stuff, including all the executables in /usr/bin, /usr/sbin, etc. For gentoo you also have portage in /usr/portage. Now I usually have more disc partitions, which I mount on /work and/or /home. The great thing about having these separate partitions is you can upgrade the kernel while leaving all your data and the files/mail/etc in your home directory completely untouched. And if you move to a newer/faster/shinier computer you can set up the operating system first (with gentoo that could take days while you sort out new hardware, download/emerge all the software you want), then just copy all your data and /home files across when you're ready. It also splits your backups into two separate sets - one for your data, which you should backup whenever it changes, e.g. once a day, and the other is a backup of your / and /usr partitions which you only need to do when you make major changes to the kernel and apps.

Where I'm going with this (apart from spruiking the virtues of the Linux filesystem) is that if you are worried about "wearing out" your SSD then you could mount the /usr/portage directory on a partition on a USB hard drive - the directory is only looked at when you're emerge'ing and doing system admin stuff, so when you're just working or watching videos the external drive doesn't need to be plugged in and mounted.

As a concrete example, if you had one big partition on your USB hard drive you could mount the drive on (say) /work. Then (as root) create a directory called portage in /work, and copy all the existing portage files into it - "cd /usr; tar cf - portage | (cd /work && tar xvfpB -)" should do the trick. Then remove the old portage "cd /usr; rm -rf portage" and create a soft link from the /usr partition to the /work partition "cd /usr; ln -s /work/portage portage". The kernel won't complain about the missing portage directories unless you actually try to access them.

Another use of links is if a disk partition is nearly full, and you want to put off re-partitioning. E.g. some software (e.g. firefox, thunderbird, etc) is installed in /opt. If your root partition is nearly full you can move the contents of /opt to a partition with lots of free space by copying the files across and the setting up the link, e.g. "cd /; ln -s /work/opt opt".

Of course, you should make sure any important stuff is backed up before fiddling with your disk partitions. (There are two kinds of computer users, those who backup regularly, and those who haven't lost any valuable data yet.)

Please ask if you've any questions. Regards, Rob.

----------

## xtx

thanks for the replies everybody, i'm starting to understand it better.

robdd, i have a freenas server mainly used for media set up. i could put portage on a folder in there, right? then soft link that location to  /usr/portage and i'd be good to go when i tried to emerge something? 

i'm asking rather than trying because i'm waiting for kde to finish emerging so it could take a bit. i hope all of the writes of emerging kde doesn't affect the life of my ssd too much, i'm not sure how sensitive they really are.

----------

## Jaglover

You can set PORTDIR and DISTDIR variables in make.conf, that's more elegant solution.

----------

## xtx

 *Jaglover wrote:*   

> You can set PORTDIR and DISTDIR variables in make.conf, that's more elegant solution.

 

i don't know what you mean by this. 

the link i posted in the original post said something vague about portdir also. i moved /usr/portage into /var/tmp (as i thought the link recommended) and set portdir="/var/tmp/portage" but when i tried to emerge something i got errors.

----------

## gorkypl

 *xtx wrote:*   

> 
> 
> i'm asking rather than trying because i'm waiting for kde to finish emerging so it could take a bit. i hope all of the writes of emerging kde doesn't affect the life of my ssd too much, i'm not sure how sensitive they really are.

 

Not THAT sensitive, but if you have >=2G of RAM then using a ramdisk for /var/tmp is usually a great idea. You can do it by simply adding one line to /etc/fstab

```
none    /var/tmp    tmpfs    defaults,noatime,mode=1777,size=2G    0    0
```

The size parameter sets the maximum amount of RAM that you allow to be used for the drive, setting it at 1/2 to 2/3 of the RAM size is quite reasonable.

----------

## xtx

 *gorkypl wrote:*   

>  *xtx wrote:*   
> 
> i'm asking rather than trying because i'm waiting for kde to finish emerging so it could take a bit. i hope all of the writes of emerging kde doesn't affect the life of my ssd too much, i'm not sure how sensitive they really are. 
> 
> Not THAT sensitive, but if you have >=2G of RAM then using a ramdisk for /var/tmp is usually a great idea. You can do it by simply adding one line to /etc/fstab
> ...

 

and setting that one line into fstab will use ram to emerge packages? even though portage is in /usr/portage, not /var/tmp?

----------

## gorkypl

Setting that line will put /var/tmp in RAM. /var/tmp is the temporary directory which portage uses to build stuff, so putting it in RAM will greatly reduce load on SSD disk. You can also do the same thing with your /tmp directory (just copy the line and change /var/tmp to /tmp).

This is a no-brainer, just do it if you have enough RAM.

Changing portage source directory is another thing and it is also worth to pay attention at it, but your idea of moving /usr/portage into /var/tmp makes no sense. 

As Jaglover said above, the best way would be to mount your remote drive somewhere in the tree (for example on /mnt/remotedrive/portage). The mount method is up to you - you can use NFS, sshfs,curlftpfs or whatever your NAS supports. Then you just set in /etc/make.conf

```

PORTDIR=/mnt/remotedrive/portage/

DISTDIR=/mnt/remotedrive/portage/distfiles

```

Then you should update your make.profile and make.globals symlinks

```

ln -sf /mnt/remotedrive/portage/profiles/default/linux/amd64/10.0/desktop /etc/make.profile

ln -sf /mnt/remotedrive/portage/config/make.globals /etc/make.globals

```

(this was made on example of amd64 desktop profile, you should change it to whatever profile you use)

Finally, you can consider what Telemin have said about mounting /var/log to tmpfs and exporting browser cache to RAM.

Witch changes described above and using a proper filesystem with TRIM support (btrfs/ext4) you should have no problems with SSD wear for 20 years  :Smile: 

----------

## xtx

wow, thanks a lot!

----------

