diff options
Diffstat (limited to 'tools/storage.html')
-rw-r--r-- | tools/storage.html | 377 |
1 files changed, 377 insertions, 0 deletions
diff --git a/tools/storage.html b/tools/storage.html new file mode 100644 index 0000000..2797f31 --- /dev/null +++ b/tools/storage.html @@ -0,0 +1,377 @@ +<!DOCTYPE html> +<html dir="ltr" lang="en"> + <head> + <meta charset='utf-8'> + <title>Storage</title> + </head> + <body> + + <a href="index.html">Systools Index</a> + + <h1>Storage</h1> + + <h2 id="mv">Moving partitions</h2> + + <pre> + var + (parted) mkpart primary ext4 57GiB 200GiB + </pre> + <pre> + swap + (parted) mkpart primary linux-swap 29GiB 57GiB + </pre> + <pre> + home + (parted) mkpart primary ext4 57GiB 200GiB + </pre> + <pre> + srv + (parted) mkpart primary ext4 200GiB 100% + </pre> + + <p>Reboot into single-user mode where services aren't started and networking is offline.<p> + <pre> + # init 1 + </pre> + + <p>Copy the data:</p> + cp -apx /srv/* /mnt/srv + + <p>Rename directory, for later backup;</p> + + <pre> + mv /srv /srv.old + mkdir /srv + </pre> + + <p>Edit the <a href="../conf/etc/fstab">/etc/fstab</a>file:</p> + + <pre> + # Server Data /srv + UUID=6fadcb98-e442-4af7-a5f2-1ddb6100a8c4 /srv ext4 defaults 0 2 + </pre> + + <p>Reboot in normal mode.</p> + + <h2 id="lvm">1.2. LVM</h2> + + <p>Read <a href="https://raid.wiki.kernel.org/index.php/RAID_setup">Raid Setup</a>, + the only thing you will need outside system is: + "Patience, Pizza, and your favorite caffeinated beverage.". + <a href="https://wiki.archlinux.org/index.php/Software_RAID_and_LVM">Arch Wiki</a> + article about Sofware RAID and LVM.</p> + + <p>Basic idea behind RAID is to deal with independent disks + as an array of drives. Raid 0 uses two or more disks as one, + with performance gains without fault-tolerance. From raid 1 + to 6 they offer diferent fault tolerance mechanisms.</p> + + <p>LVM or Logic Volume Manager bring one more layer, read + <a href="http://www.tuxradar.com/content/lvm-made-easy">Lvm made easy</a>. + Partitions under lvm are easy to be resized, moved and there is + a tool to help encrypt. There is more freedom to name physical + disk names exp; production, development, backups...</p> + + + <p>Until now "from install" there is only one partition, + it is good idea to have a system with diferent partitions for each + propos. If is a "fresh install";</p> + + <pre> + # cd /iso/crux/opt/ + # pkgadd lvm2#2.02.107-1.pkg.tar.xz + # + </pre> + + <h3>Multiple Partition</h3> + + <p>Create a LVM partition, fdisk should + show something like this;</p> + + <pre> + # fdisk /dev/sdb + + Welcome to fdisk (util-linux 2.26.1). + Changes will remain in memory only, until you decide to write them. + Be careful before using the write command. + + + Command (m for help): p + Disk /dev/sdb: 232.9 GiB, 250059350016 bytes, 488397168 sectors + Units: sectors of 1 * 512 = 512 bytes + Sector size (logical/physical): 512 bytes / 512 bytes + I/O size (minimum/optimal): 512 bytes / 512 bytes + Disklabel type: gpt + Disk identifier: E37FE96F-9845-45A4-B6DA-BF3F8E47511A + + Device Start End Sectors Size Type + /dev/sdb1 2048 8056 6009 3M BIOS boot + /dev/sdb2 8192 18440191 18432000 8.8G Linux filesystem + + Command (m for help): + </pre> + + <p>I use defaults unless to define system partition last sector, + where in this example is size, +80G</p> + + <pre> + Command (m for help): n + Partition number (3-128, default 3): + First sector (8057-488397134, default 18440192): + Last sector, +sectors or +size{K,M,G,T,P} (18440192-488397134, default 488397134): +80G + + Created a new partition 3 of type 'Linux filesystem' and of size 80 GiB. + + Command (m for help): + + Command (m for help): t + Partition number (1-3, default 3): + Hex code (type L to list all codes): 23 + + Changed type of partition 'Linux filesystem' to 'Linux LVM'. + + Command (m for help): n + Partition number (4-128, default 4): + First sector (8057-488397134, default 186212352): + Last sector, +sectors or +size{K,M,G,T,P} (186212352-488397134, default 488397134): + + Created a new partition 4 of type 'Linux filesystem' and of size 144.1 GiB. + + Command (m for help): t + Partition number (1-4, default 4): + Hex code (type L to list all codes): 23 + + Changed type of partition 'Linux filesystem' to 'Linux LVM'. + + Command (m for help): w + The partition table has been altered. + Calling ioctl() to re-read partition table. + Syncing disks. + + # + </pre> + + <h3>Create Phisical Volume</h3> + + + <pre> + # pvcreate /dev/sdb3 + Physical volume "/dev/sdb3" successfully created + # + # pvcreate /dev/sdb4 + Physical volume "/dev/sdb4" successfully created + # + </pre> + + <h3>Create Volume Group</h3> + + <pre> + # vgcreate systemvg /dev/sdb3 + Volume group "systemvg" successfully created + # vgcreate homevg /dev/sdb4 + Volume group "homevg" successfully created + # + </pre> + + <h3>Create Logical Volume</h3> + + <pre> + # lvcreate -L 15G -n distfileslv systemvg + Logical volume "distfileslv" created. + # lvcreate -L 8G -n packageslv systemvg + Logical volume "packageslv" created. + # lvcreate -L 4G -n swaplv systemvg + Logical volume "swaplv" created. + # lvcreate -L 80G -n homelv homevg + Logical volume "homelv" created. + # + </pre> + + <pre> + # mkfs.ext4 /dev/systemvg/distfileslv + # mkfs.ext4 /dev/systemvg/packageslv + # mkswap /dev/systemvg/swaplv + # mkfs.ext4 /dev/homevg/homelv + </pre> + + <h3>Activate Deactivate</h3> + + <p>Deactivate logical volumes;</p> + + <pre> + # lvchange -a -n /dev/systemvg/packageslv + # lvchange -a -n /dev/systemvg/distfileslv + # swapoff /dev/systemvg/sawplv + # lvchange -a -n /dev/systemvg/swaplv + </pre> + + <p>Deactivate volume group;</p> + + <pre> + # vgchange -a n systemvg + 0 logical volume(s) in volume group "systemvg" now active + # + </pre> + + <p>Activate volume group;</p> + <pre> + # vgchange -a y systemvg + 3 logical volume(s) in volume group "systemvg" now active + # + </pre> + + <h3>Search Volume Groups</h3> + + <pre> + # vgscan + Reading all physical volumes. This may take a while... + Found volume group "homevg" using metadata type lvm2 + Found volume group "systemvg" using metadata type lvm2 + # + </pre> + + <h3>Reconfigure System</h3> + + <p>Start by mounting distfileslv and packageslv;</p> + + <pre> + # mkdir -p /var/ports/distfiles + # mkdir -p /var/ports/packages + # mkdir -p /var/ports/work + # mkdir -p /var/ports/pkgbuild + # chown -R pkgmk:pkgmk /var/ports + # + </pre> + + <pre> + # vim /etc/pkgmk.conf + + # PKGMK_SOURCE_MIRRORS=() + PKGMK_SOURCE_DIR="/var/ports/distfiles" + PKGMK_PACKAGE_DIR="/var/ports/packages" + PKGMK_WORK_DIR="/var/ports/work/$name + </pre> + + <p>Edit /etc/prt-get.conf;</p> + + <pre> + ### log options: + writelog enabled # (enabled|disabled) + logmode overwrite # (append|overwrite) + rmlog_on_success yes # (no|yes) + logfile /var/ports/pkgbuild/%n.log + </pre> + + <pre> + # + # /etc/fstab: static file system information + # + # <file system> <dir> <type> <options> <dump> <pass> + + UUID=49031e4e-f899-499d-ac83-401ad12635f5 / ext4 defaults,errors=remount-ro,noatime 0 1 + + #/dev/mapper/homevg-homelv: + UUID=c3158626-de78-4bfa-ab8a-9e7e157eca88 /home ext4 defaults,noatime 0 2 + + #/dev/mapper/systemvg-distfileslv: + UUID=0aba2d28-8e3a-4a89-bff5-1698708e13d0 /var/ports/distfiles ext4 defaults,noatime 0 2 + #/dev/mapper/systemvg-packageslv: + UUID=b5a38930-2827-4f00-809a-a0c4d5488aa8 /var/ports/packages ext4 defaults,noatime 0 2 + + #/dev/mapper/systemvg-swaplv: + UUID=08295a67-a056-4dea-9462-209f151e4cdf swap swap defaults 0 0 + devpts /dev/pts devpts noexec,nosuid,gid=tty,mode=0620 0 0 + tmp /tmp tmpfs defaults 0 0 + shm /dev/shm tmpfs defaults 0 0 + + pkgmk /var/ports/work tmpfs size=1G,uid=100,defaults 0 0 + # End of file + </pre> + + <p>You can move home directory to new one with + just one command; "usermod -m -d /home/new user".</p> + + <pre> + # mount /var/ports/distfiles + # mount /var/ports/packages + # umount /home/pkgmk/work + # mount /var/ports/work + # mv /home/pkgmk/distfiles/* /var/ports/distfiles/ + # mv /home/pkgmk/packages/* /var/ports/packages/ + # rm -R /home/pkgmk + # usermod -d /var/ports pkgmk + </pre> + + <p>Check ownership, you may need recursive if partition + has bin used on another system.</p> + + <pre> + # chown pkgmk:pkgmk /var/ports/distfiles + # chown pkgmk:pkgmk /var/ports/packages + # + </pre> + + <pre> + # mkdir /home/tmp + # mount /dev/homevg/homelv /home/tmp + # mv /home/user /home/tmp + # umount /home/tmp + # rmdir /home/tmp + # rm -R /home/user + </pre> + + <h2>Maintenance</h2> + + <pre> + # smartctl -t long /dev/sdb1 + # smartctl -a /dev/sdb1 | less + </pre> + + + <p><a href="https://wiki.archlinux.org/index.php/Badblocks">Non Destructive Test;</a></p> + + <pre> + # badblocks -nsv /dev/sdb1 + </pre> + + + <h2>Example gitolite volume</h2> + + <p>Lets create new lvm volume for repositories data;</p> + + <pre> + # lvcreate -L 15G -n gitlv homevg + Logical volume "gitlv" created. + + # mkfs.ext4 /dev/homevg/gitlv + mke2fs 1.42.12 (29-Aug-2014) + Creating filesystem with 3932160 4k blocks and 983040 inodes + Filesystem UUID: 54c7dca5-1558-4f90-8d81-c01e4e50c6ae + Superblock backups stored on blocks: + 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208 + + Allocating group tables: done + Writing inode tables: done + Creating journal (32768 blocks): done + Writing superblocks and filesystem accounting information: done + + # + </pre> + + <p>Edit fstab</p> + + <pre> + UUID=54c7dca5-1558-4f90-8d81-c01e4e50c6ae /srv/git ext4 defaults,noatime 0 2 + </pre> + + <h2 id="btrfs">1.3. BTRFS</h2> + + <a href="index.html">Systools Index</a> + <p> + This is part of the c9-doc Manual. + Copyright (C) 2016 + Silvino Silva. + See the file <a href="../fdl-1.3-standalone.html">Gnu Free Documentation License</a> + for copying conditions.</p> + </body> +</html> |