From 07bedee34d9ded6f86904c7e4b4e02464ff8cb14 Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Thu, 15 Sep 2016 00:47:34 +0100 Subject: added tools --- tools/storage.html | 377 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 377 insertions(+) create mode 100644 tools/storage.html (limited to 'tools/storage.html') 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 @@ + + + + + Storage + + + + Systools Index + +

Storage

+ +

Moving partitions

+ +
+        var
+        (parted) mkpart primary ext4 57GiB 200GiB
+        
+
+        swap
+        (parted) mkpart primary linux-swap 29GiB 57GiB
+        
+
+        home
+        (parted) mkpart primary ext4 57GiB 200GiB
+        
+
+        srv
+        (parted) mkpart primary ext4 200GiB 100%
+        
+ +

Reboot into single-user mode where services aren't started and networking is offline.

+

+        # init 1
+        
+ +

Copy the data:

+ cp -apx /srv/* /mnt/srv + +

Rename directory, for later backup;

+ +
+        mv /srv /srv.old
+        mkdir /srv
+        
+ +

Edit the /etc/fstabfile:

+ +
+        # Server Data /srv
+        UUID=6fadcb98-e442-4af7-a5f2-1ddb6100a8c4 /srv            ext4    defaults        0       2
+        
+ +

Reboot in normal mode.

+ +

1.2. LVM

+ +

Read Raid Setup, + the only thing you will need outside system is: + "Patience, Pizza, and your favorite caffeinated beverage.". + Arch Wiki + article about Sofware RAID and LVM.

+ +

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.

+ +

LVM or Logic Volume Manager bring one more layer, read + Lvm made easy. + 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...

+ + +

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";

+ +
+        # cd /iso/crux/opt/
+        # pkgadd lvm2#2.02.107-1.pkg.tar.xz
+        #
+        
+ +

Multiple Partition

+ +

Create a LVM partition, fdisk should + show something like this;

+ +
+        # 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):
+        
+ +

I use defaults unless to define system partition last sector, + where in this example is size, +80G

+ +
+        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.
+
+        #
+        
+ +

Create Phisical Volume

+ + +
+         # pvcreate /dev/sdb3
+          Physical volume "/dev/sdb3" successfully created
+         #
+         # pvcreate /dev/sdb4
+          Physical volume "/dev/sdb4" successfully created
+         #
+        
+ +

Create Volume Group

+ +
+        # vgcreate systemvg /dev/sdb3
+          Volume group "systemvg" successfully created
+        # vgcreate homevg /dev/sdb4
+          Volume group "homevg" successfully created
+        #
+        
+ +

Create Logical Volume

+ +
+        # 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.
+        #
+        
+ +
+        # mkfs.ext4 /dev/systemvg/distfileslv
+        # mkfs.ext4 /dev/systemvg/packageslv
+        # mkswap /dev/systemvg/swaplv
+        # mkfs.ext4 /dev/homevg/homelv
+        
+ +

Activate Deactivate

+ +

Deactivate logical volumes;

+ +
+        # lvchange -a -n /dev/systemvg/packageslv
+        # lvchange -a -n /dev/systemvg/distfileslv
+        # swapoff /dev/systemvg/sawplv
+        # lvchange -a -n /dev/systemvg/swaplv
+        
+ +

Deactivate volume group;

+ +
+         # vgchange -a n systemvg
+         0 logical volume(s) in volume group "systemvg" now active
+         #
+        
+ +

Activate volume group;

+
+        # vgchange -a y systemvg
+          3 logical volume(s) in volume group "systemvg" now active
+        #
+        
+ +

Search Volume Groups

+ +
+        # 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
+        #
+        
+ +

Reconfigure System

+ +

Start by mounting distfileslv and packageslv;

+ +
+        # 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
+        #
+        
+ +
+        # 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
+        
+ +

Edit /etc/prt-get.conf;

+ +
+        ### log options:
+        writelog enabled           # (enabled|disabled)
+        logmode  overwrite         # (append|overwrite)
+        rmlog_on_success yes       # (no|yes)
+        logfile  /var/ports/pkgbuild/%n.log
+        
+ +
+        #
+        # /etc/fstab: static file system information
+        #
+        #                                           
+
+        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
+        
+ +

You can move home directory to new one with + just one command; "usermod -m -d /home/new user".

+ +
+        # 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
+        
+ +

Check ownership, you may need recursive if partition + has bin used on another system.

+ +
+        # chown pkgmk:pkgmk /var/ports/distfiles
+        # chown pkgmk:pkgmk /var/ports/packages
+        #
+        
+ +
+        # mkdir /home/tmp
+        # mount /dev/homevg/homelv /home/tmp
+        # mv /home/user /home/tmp
+        # umount /home/tmp
+        # rmdir /home/tmp
+        # rm -R /home/user
+        
+ +

Maintenance

+ +
+        # smartctl -t long /dev/sdb1
+        # smartctl -a /dev/sdb1 | less
+        
+ + +

Non Destructive Test;

+ +
+        # badblocks -nsv /dev/sdb1
+        
+ + +

Example gitolite volume

+ +

Lets create new lvm volume for repositories data;

+ +
+        # 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
+
+         #
+        
+ +

Edit fstab

+ +
+        UUID=54c7dca5-1558-4f90-8d81-c01e4e50c6ae       /srv/git                ext4 defaults,noatime   0 2
+        
+ +

1.3. BTRFS

+ + Systools Index +

+ This is part of the c9-doc Manual. + Copyright (C) 2016 + Silvino Silva. + See the file Gnu Free Documentation License + for copying conditions.

+ + -- cgit 1.4.1-2-gfad0 3:41:16 -0400 added functionality to update posts' href='/gbmor/clinte/commit/src/main.rs?h=v0.4.3&id=ca7dc5870b5581ba5d5d2c097745fff5b7a072d5'>ca7dc58 ^
d64124e ^
05649a5 ^
5b59ba3 ^
05649a5 ^
5b59ba3 ^
99273b6 ^
05649a5 ^
94e8df5 ^
05649a5 ^
fd2f770 ^
b50586f ^
8b3c06f ^
fd2f770 ^
eca1e0a ^


ca7dc58 ^
fd2f770 ^
b50586f ^
8b3c06f ^
fd2f770 ^
eca1e0a ^


ebc4efa ^
fd2f770 ^
05649a5 ^
8d50587 ^
fd2f770 ^


05649a5 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61