Skillnad mellan versioner av "Generic-cli"
Js146669 (Diskussion | bidrag) |
Js146669 (Diskussion | bidrag) |
||
Rad 22: | Rad 22: | ||
# lvreduce | # lvreduce | ||
# lvrename | # lvrename | ||
+ | |||
+ | == Rename Root Vol == | ||
+ | To change the root vol name, boot from a bootable ISO or CDROM<br> | ||
+ | Login and run the following | ||
+ | # vgrename <old-vg> <new-vg> | ||
+ | |||
+ | Mount the root disk & required sub filesystems | ||
+ | # mount /dev/<new-vg> /mnt | ||
+ | # mount --bind /proc /mnt/proc/ | ||
+ | # mount --bind /sys /mnt/sys/ | ||
+ | # mount --bind /dev /mnt/dev/ | ||
+ | # mount /dev/sda1 /mnt/boot/ | ||
+ | # chroot /mnt | ||
+ | |||
+ | Edit the fstab and grub files | ||
+ | # sed -i 's/<old-vg>/<new-vg>/g' /etc/fstab | ||
+ | # sed -i 's/<old-vg>/<new-vg>/g' /etc/default/grub | ||
+ | |||
+ | Use grub2-mkconfig | ||
+ | # grub2-mkconfig -o /boot/grub/grub.cfg | ||
+ | |||
+ | Create new kernel initramfs/initrd image file using a specific kernel version. | ||
+ | # dracut --force --kver <choose kernel vers> | ||
+ | |||
+ | ''Tips! Run <uname -r > to show the active kernel version or check for different versions in </boot> for required kernel name.'' | ||
+ | |||
+ | Use the following to check content of new initramfs/initrd image | ||
+ | List entire content | ||
+ | # lsinitrd <path-to-image> | ||
+ | View a specific file from the image file | ||
+ | # lsinitrd -f /etc/fstab <path-to-image> | ||
+ | |||
+ | unmount chroot & reboot | ||
+ | # umount -f /mnt | ||
+ | # shutdown -h now | ||
+ | Remove cdrom/ISO and reboot. | ||
== RPM == | == RPM == |
Versionen från 14 november 2017 kl. 15.07
Innehåll
Disks/PV/VG/LV info
Display a more readable output of disks/vols/mountpoints on Linux
# lsblk -i
Physical Volumes
# pvscan # pvdisplay
Volume Groups
# vgscan # vgdisplay # vgchange # vgrename # vgs
Logical Volumes
# lvscan # lgscan # lvdisplay # lvchange # lvs # lvresize # lvextend # lvreduce # lvrename
Rename Root Vol
To change the root vol name, boot from a bootable ISO or CDROM
Login and run the following
# vgrename <old-vg> <new-vg>
Mount the root disk & required sub filesystems
# mount /dev/<new-vg> /mnt # mount --bind /proc /mnt/proc/ # mount --bind /sys /mnt/sys/ # mount --bind /dev /mnt/dev/ # mount /dev/sda1 /mnt/boot/ # chroot /mnt
Edit the fstab and grub files
# sed -i 's/<old-vg>/<new-vg>/g' /etc/fstab # sed -i 's/<old-vg>/<new-vg>/g' /etc/default/grub
Use grub2-mkconfig
# grub2-mkconfig -o /boot/grub/grub.cfg
Create new kernel initramfs/initrd image file using a specific kernel version.
# dracut --force --kver <choose kernel vers>
Tips! Run <uname -r > to show the active kernel version or check for different versions in </boot> for required kernel name.
Use the following to check content of new initramfs/initrd image
List entire content # lsinitrd <path-to-image> View a specific file from the image file # lsinitrd -f /etc/fstab <path-to-image>
unmount chroot & reboot
# umount -f /mnt # shutdown -h now
Remove cdrom/ISO and reboot.
RPM
Find out what pkg a file belongs to
# rpm -qf <path-to-file/cmd>
Find out if a file was installed as part of a pkg
# rpm -ql /usr/liblibXp.so.6
Display system-wide config files for a cmd
# rpm -qcf /bin/bash
Check contents of RPM
# rpm -qlp RPMTOPDIR/RPMS/x86_64/<name-of-pkg>.rpm
To view different architecture version of a pkg
# rpm -q --queryformat "%{name}.%{arch}\n" pdksh-5.2.14-36.el5
GREP
grep for soltec in start of line
# grep ^"soltec"
grep for soltec at end of line
# grep "soltec"$
YUM
to install all pkgs in listed in file
# yum install $(< test.txt) # yum -y install $(cat list)
Display history
# yum history # yum history info # yum history list
VI
dG delete from line to end of file d1G delete to top including current line dgg delete from line to start of file G goto last line in file 1G to to first line in file 0 goto start of line $ goto end of line :set number <--to display line numbers :color desert <--to change display colours
Copy/Move data
To move data on the same system, use the following:
# cd dir1 && tar -cf - . | (cd dir2 && tar -xpvf -)
dir1 is the directory you want to copy. dir2 is the directory in which you want the copy to go. This tar’s the current directory to STDOUT, then changes directory, and untar’s the archive without ever having to find the space for a .tar file.
Use the following to do this across systems via ssh:
# cd dir1 && tar -cf - . | ssh system2 "cd dir2 && tar -xpvf -"
RSYNC/RSYNCD
Use rysncd instead of rsync to use resources on the target system copying the data instead of source server