Linux Tipps und Tricks: Difference between revisions
No edit summary |
No edit summary |
||
Line 45: | Line 45: | ||
[2:0:0:0] cd/dvd NECVMWar VMware SATA CD00 1.00 /dev/sr0 | [2:0:0:0] cd/dvd NECVMWar VMware SATA CD00 1.00 /dev/sr0 | ||
[32:0:1:0] disk VMware Virtual disk 1.0 /dev/sda | [32:0:1:0] disk VMware Virtual disk 1.0 /dev/sda | ||
</source> | |||
==Resize a GPT partition== | |||
The partition was resized in VMWare from ~6GB to ~50GB. | |||
===Correct the GPT partition table=== | |||
<source lang=bash> | |||
root@mariadb:~# parted /dev/sdb | |||
GNU Parted 3.2 | |||
Using /dev/sdb | |||
Welcome to GNU Parted! Type 'help' to view a list of commands. | |||
(parted) p | |||
Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of the space (an extra 92274688 blocks) or continue with the | |||
current setting? | |||
Fix/Ignore? F <-- ! choose F | |||
Model: VMware Virtual disk (scsi) | |||
Disk /dev/sdb: 53,7GB <-- ! the new size is reported now | |||
Sector size (logical/physical): 512B/512B | |||
Partition Table: gpt | |||
Disk Flags: | |||
Number Start End Size File system Name Flags | |||
1 1049kB 6442MB 6441MB zfs | |||
</source> | |||
===Resize the partition=== | |||
<source lang=bash> | |||
root@mariadb:~# parted /dev/sdb | |||
GNU Parted 3.2 | |||
Using /dev/sdb | |||
Welcome to GNU Parted! Type 'help' to view a list of commands. | |||
(parted) p | |||
Model: VMware Virtual disk (scsi) | |||
Disk /dev/sdb: 53,7GB | |||
Sector size (logical/physical): 512B/512B | |||
Partition Table: gpt | |||
Disk Flags: | |||
Number Start End Size File system Name Flags | |||
1 1049kB 6442MB 6441MB zfs | |||
(parted) resizepart 1 | |||
End? [6442MB]? 53,7GB <-- ! Put new size here | |||
(parted) p <-- ! Control if it worked | |||
Model: VMware Virtual disk (scsi) | |||
Disk /dev/sdb: 53,7GB | |||
Sector size (logical/physical): 512B/512B | |||
Partition Table: gpt | |||
Disk Flags: | |||
Number Start End Size File system Name Flags | |||
1 1049kB 53,7GB 53,7GB zfs | |||
(parted) q | |||
Information: You may need to update /etc/fstab. | |||
</source> | |||
===Optional: Resize the ZPool in it=== | |||
Check the actual values: | |||
<source lang=bash> | |||
root@mariadb:~# zpool list MYSQL-DATA | |||
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT | |||
MYSQL-DATA 5,97G 994M 5,00G 44G 47% 16% 1.00x ONLINE - | |||
root@mariadb:~# zpool get autoexpand MYSQL-DATA | |||
NAME PROPERTY VALUE SOURCE | |||
MYSQL-DATA autoexpand off default | |||
</source> | |||
Now inform ZPool to grow to the end of the partition. | |||
Set autoexpand to on: | |||
<source lang=bash> | |||
root@mariadb:~# zpool set autoexpand=on MYSQL-DATA | |||
</source> | |||
Send an online to the already onlined device to force a recheck in the ZPool to resize it without export/import: | |||
<source lang=bash> | |||
root@mariadb:~# zpool online MYSQL-DATA /dev/sdb1 | |||
</source> | |||
Et voila: | |||
<source lang=bash> | |||
root@mariadb:~# zpool list MYSQL-DATA | |||
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT | |||
MYSQL-DATA 50,0G 994M 49,0G - 5% 1% 1.00x ONLINE - | |||
rpool 19,9G 3,36G 16,5G - 19% 16% 1.00x ONLINE - | |||
</source> | |||
Set autoexpand to off if you want prevent to autoexpand if partition grows: | |||
<source lang=bash> | |||
root@mariadb:~# zpool set autoexpand=off MYSQL-DATA | |||
</source> | </source> |
Revision as of 13:10, 21 October 2016
Hard reboot
This is the hard way to kick your kernel into void. No filesystem sync is done, just an ugly fast direkt reboot! You should never do this...
# echo 1 > /proc/sys/kernel/sysrq
# echo b > /proc/sysrq-trigger
First line enables sysrq, second line sends the reboot request.
For more look at kernel.org!
Scan all SCSI buses for new devices
# for i in /sys/class/scsi_host/host*/scan ; do echo "- - -" > $i ; done
Remove a SCSI-device
Let us say we want to remove /dev/sdb.
Be careful! Like in this example the lowest SCSI-ID is not always the lowest device name! Check it with lsscsi from the Ubuntu package lsscsi:
# lsscsi
[2:0:0:0] cd/dvd NECVMWar VMware SATA CD00 1.00 /dev/sr0
[32:0:0:0] disk VMware Virtual disk 1.0 /dev/sdb
[32:0:1:0] disk VMware Virtual disk 1.0 /dev/sda
Then check it is not longer in use:
- mount
- pvs
- zpool status
- etc.
Then delete it:
# echo 1 > /sys/bus/scsi/drivers/sd/32\:0\:0\:0/delete
The 32:0:0:0 is the number reported from the lsscsi above.
Et voila:
# lsscsi
[2:0:0:0] cd/dvd NECVMWar VMware SATA CD00 1.00 /dev/sr0
[32:0:1:0] disk VMware Virtual disk 1.0 /dev/sda
Resize a GPT partition
The partition was resized in VMWare from ~6GB to ~50GB.
Correct the GPT partition table
root@mariadb:~# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of the space (an extra 92274688 blocks) or continue with the
current setting?
Fix/Ignore? F <-- ! choose F
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 53,7GB <-- ! the new size is reported now
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 6442MB 6441MB zfs
Resize the partition
root@mariadb:~# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 53,7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 6442MB 6441MB zfs
(parted) resizepart 1
End? [6442MB]? 53,7GB <-- ! Put new size here
(parted) p <-- ! Control if it worked
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 53,7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 53,7GB 53,7GB zfs
(parted) q
Information: You may need to update /etc/fstab.
Optional: Resize the ZPool in it
Check the actual values:
root@mariadb:~# zpool list MYSQL-DATA
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
MYSQL-DATA 5,97G 994M 5,00G 44G 47% 16% 1.00x ONLINE -
root@mariadb:~# zpool get autoexpand MYSQL-DATA
NAME PROPERTY VALUE SOURCE
MYSQL-DATA autoexpand off default
Now inform ZPool to grow to the end of the partition. Set autoexpand to on:
root@mariadb:~# zpool set autoexpand=on MYSQL-DATA
Send an online to the already onlined device to force a recheck in the ZPool to resize it without export/import:
root@mariadb:~# zpool online MYSQL-DATA /dev/sdb1
Et voila:
root@mariadb:~# zpool list MYSQL-DATA
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
MYSQL-DATA 50,0G 994M 49,0G - 5% 1% 1.00x ONLINE -
rpool 19,9G 3,36G 16,5G - 19% 16% 1.00x ONLINE -
Set autoexpand to off if you want prevent to autoexpand if partition grows:
root@mariadb:~# zpool set autoexpand=off MYSQL-DATA