Wednesday, December 11, 2019
Command line loops every line in file (DOS & SHELL)
DOS
for /f %i in (filename.txt) do echo %i
SHELL
while IFS= read -r line; do echo $line; done < filename.txt
Labels:
cmd,
command line,
dos,
loop file content,
looping file content,
shell
Saturday, July 27, 2019
RHEL Add New HDD / New SAS / New Storage
- Slot in the new drive
- List the drive in the RHEL terminal console and find the newly slot in drive
[user01@cybertech01 ~]$ ls /dev/sd*
/dev/sda /dev/sda2 /dev/sda4 /dev/sda6 /dev/sdb /dev/sdc
/dev/sda1 /dev/sda3 /dev/sda5 /dev/sda7 /dev/sdb1
[user01@cybertech01 ~]$ sudo fdisk -l
[sudo] password for user01:
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 4000.8 GB, 4000787030016 bytes
255 heads, 63 sectors/track, 486401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf943de38
Device Boot Start End Blocks Id System
/dev/sda1 1 267350 2147483647+ ee GPT
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdb: 4000.8 GB, 4000787030016 bytes
255 heads, 63 sectors/track, 486401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 1 267350 2147483647+ ee GPT
Disk /dev/sdc: 9796.8 GB, 9796820402176 bytes
255 heads, 63 sectors/track, 1191062 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
For Storage >2GB MUST use GPT to partition the drive.
[user01@cybertech01 ~]$ sudo parted /dev/sdc
GNU Parted 2.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: HGST HUH721010AL5200 (scsi)
Disk /dev/sdc: 9797GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Number Start End Size Type File system Flags
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart primary 0GB 9796.8GB
(parted) print
Model: HGST HUH721010AL5200 (scsi)
Disk /dev/sdc: 9797GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 9797GB 9797GB primary
(parted) quit
Information: You may need to update /etc/fstab.
Format partitioned drive
[user01@cybertech01 ~]$ ls /dev/sdc*
/dev/sdc /dev/sdc1
[user01@cybertech01 ~]$ sudo mkfs /dev/sdc1
[sudo] password for user01:
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
597950464 inodes, 2391801344 blocks
119590067 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
72992 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544, 1934917632
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
3. Create mountable drive for new drive in filesystem
[user01@cybertech01 /]$ sudo mkdir /data2
[sudo] password for user01:
[user01@cybertech01 /]$ ls -l
total 116
dr-xr-xr-x. 2 root root 4096 Nov 4 2016 bin
dr-xr-xr-x. 5 root root 4096 Jun 15 2015 boot
drwxr-xr-x. 10 root root 4096 Jun 15 2015 cgroup
drwxrwxrwx. 4 root root 4096 Jul 17 16:03 data
drwxr-xr-x. 2 root root 4096 Jul 27 01:18 data2
drwxr-xr-x. 18 root root 4160 Jul 27 00:45 dev
drwxr-xr-x. 141 root root 12288 Jul 26 03:37 etc
drwxr-xr-x. 11 root root 4096 Jan 11 2018 home
drwxr-xr-x. 2 root root 4096 Jun 17 2015 ISOs
dr-xr-xr-x. 11 root root 4096 Jun 15 2015 lib
dr-xr-xr-x. 10 root root 12288 Nov 4 2016 lib64
drwx------. 2 root root 16384 Jun 15 2015 lost+found
drwxr-xr-x. 2 root root 4096 May 15 2018 media
drwxr-xr-x. 2 root root 0 Jun 15 20:35 misc
drwxr-xr-x. 2 root root 4096 Jun 28 2011 mnt
drwxr-xr-x. 2 root root 0 Jun 15 20:35 net
drwxr-xr-x. 4 root root 4096 Jan 11 2018 opt
dr-xr-xr-x. 210 root root 0 Jun 15 20:32 proc
dr-xr-x---. 31 root root 4096 May 15 2018 root
dr-xr-xr-x. 2 root root 12288 Dec 7 2016 sbin
drwxr-xr-x. 7 root root 0 Jun 15 20:32 selinux
drwxr-xr-x. 2 root root 4096 Jun 28 2011 srv
drwxr-xr-x. 13 root root 0 Jun 15 20:32 sys
drwxrwxrwt. 24 root root 4096 Jul 26 07:25 tmp
drwxr-xr-x. 13 root root 4096 Jun 15 2015 usr
drwxr-xr-x. 25 root root 4096 Jun 18 2015 var
[user01@cybertech01 /]$ sudo chmod 777 data2
[user01@cybertech01 /]$ ls -l
total 116
dr-xr-xr-x. 2 root root 4096 Nov 4 2016 bin
dr-xr-xr-x. 5 root root 4096 Jun 15 2015 boot
drwxr-xr-x. 10 root root 4096 Jun 15 2015 cgroup
drwxrwxrwx. 4 root root 4096 Jul 17 16:03 data
drwxrwxrwx. 2 root root 4096 Jul 27 01:18 data2
drwxr-xr-x. 18 root root 4160 Jul 27 00:45 dev
drwxr-xr-x. 141 root root 12288 Jul 26 03:37 etc
drwxr-xr-x. 11 root root 4096 Jan 11 2018 home
drwxr-xr-x. 2 root root 4096 Jun 17 2015 ISOs
dr-xr-xr-x. 11 root root 4096 Jun 15 2015 lib
dr-xr-xr-x. 10 root root 12288 Nov 4 2016 lib64
drwx------. 2 root root 16384 Jun 15 2015 lost+found
drwxr-xr-x. 2 root root 4096 May 15 2018 media
drwxr-xr-x. 2 root root 0 Jun 15 20:35 misc
drwxr-xr-x. 2 root root 4096 Jun 28 2011 mnt
drwxr-xr-x. 2 root root 0 Jun 15 20:35 net
drwxr-xr-x. 4 root root 4096 Jan 11 2018 opt
dr-xr-xr-x. 210 root root 0 Jun 15 20:32 proc
dr-xr-x---. 31 root root 4096 May 15 2018 root
dr-xr-xr-x. 2 root root 12288 Dec 7 2016 sbin
drwxr-xr-x. 7 root root 0 Jun 15 20:32 selinux
drwxr-xr-x. 2 root root 4096 Jun 28 2011 srv
drwxr-xr-x. 13 root root 0 Jun 15 20:32 sys
drwxrwxrwt. 24 root root 4096 Jul 26 07:25 tmp
drwxr-xr-x. 13 root root 4096 Jun 15 2015 usr
drwxr-xr-x. 25 root root 4096 Jun 18 2015 var
4. Mount drive - auto mount drive every time machine boot up
[user01@cybertech01 ~]$ cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Jun 15 19:08:42 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=e75996a4-7fe7-47e2-8555-729c65595ad5 / ext4 defaults 1 1
UUID=5dbfeb72-a62e-40a3-9bf7-94bbff1e13f2 /boot ext4 defaults 1 2
UUID=DD53-1ACA /boot/efi vfat umask=0077,shortname=winnt 0 0
UUID=8c5a4548-10fb-4958-aaaa-ef09e630de15 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/ISOs/rhel-server-6.5-x86_64-dvd.iso /var/OSimage/RHEL6.5_x86_64 iso9660 loop,ro 0 0
/dev/sdb1 /data ext4 auto,user,rw 1 2
[user01@cybertech01 ~]$ sudo vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Jun 15 19:08:42 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=e75996a4-7fe7-47e2-8555-729c65595ad5 / ext4 defaults 1 1
UUID=5dbfeb72-a62e-40a3-9bf7-94bbff1e13f2 /boot ext4 defaults 1 2
UUID=DD53-1ACA /boot/efi vfat umask=0077,shortname=winnt 0 0
UUID=8c5a4548-10fb-4958-aaaa-ef09e630de15 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/ISOs/rhel-server-6.5-x86_64-dvd.iso /var/OSimage/RHEL6.5_x86_64 iso9660 loop,ro 0 0
/dev/sdb1 /data ext4 auto,user,rw 1 2
/dev/sdc1 /data2 ext4 auto,user,rw 1 2
5. Reboot to confirm the auto-mount is correct, do expect slow boot up if the drive is large drive.
[user01@cybertech01 /]$ sudo reboot
Broadcast message from user01@cybertech01
(/dev/pts/0) at 1:20 ...
The system is going down for reboot NOW!
[user01@cybertech01 /]$
To confirm the new drive is mounted and confirm the storage space.
[user01@cybertech01 /]$ df
Credits to the reference page below:
Formating / partitioning new drive
https://www.thegeekstuff.com/2012/08/2tb-gtp-parted/
Auto mount drive:
https://www.techotopia.com/index.php/Adding_a_New_Disk_Drive_to_an_RHEL_6_System
To clear if wrongly partition:
https://www.cyberciti.biz/faq/linux-how-to-delete-a-partition-with-fdisk-command/
Labels:
add hdd,
add new sas drive,
add storage,
new hdd,
new storage
Subscribe to:
Posts (Atom)