debian wheezy - how to mount unused disks? - linux

I'm mostly a database guy but i have debian wheezy server with 4 hard disks. It was set up using one disk a while back, that one was all that was needed. Now, i need more space and the thing, i think, that is throwing me off is the UUID disk stuff.
anyway:
/mnt# lsblk -io KNAME,TYPE,SIZE,MODEL
KNAME TYPE SIZE MODEL
sdb disk 232.9G Hitachi HDP72502
sdc disk 232.9G Hitachi HDP72502
sda disk 232.9G Hitachi HDP72502
sda1 part 223.4G
sda2 part 1K
sda5 part 9.5G
sdd disk 232.9G Hitachi HDP72502
sr0 rom 1024M DVD A DS8A1P
Root is mounted to sda. sdb, c and d are unused, unformatted etc. i just need some more space, so i have created /mnt/ext_b/ and so on for b, c, d.
mount shows:
/dev/disk/by-uuid/1b1e97e4-3c04-4e50-8e06-b16752778717 on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
which is correct. i want to mount the others just for space, how do i get their UUIDs?
/mnt# blkid
/dev/sda5: UUID="f70ad0b2-a9d0-430a-829c-d2e37245fd71" TYPE="swap"
/dev/sda1: UUID="1b1e97e4-3c04-4e50-8e06-b16752778717" TYPE="ext4"
how do i get the UUIDs to put formatted filesystems on the disks?
/mnt# mkfs.ext4 /dev/sdb1
mke2fs 1.42.5 (29-Jul-2012)
Could not stat /dev/sdb1 --- No such file or directory
thanks in advance.
matt

It seems that those additional disks haven't been touched since they were connected to the server and don't have even partitions yet. In general, adding extra disk space in Linux can be done in the following steps:
Attach new disk to the server
Create partition table on it
Add one or more partitions to the disk
Format partition to the FS of your choice
Mounting this partition to the mount point of your choice
Make those mount persistent by adding appropriate line to the /etc/fstab
If you have multiple disks you may consider to create hardware RAID disk if you have RAID controller or software RAID, using mdadm tool. Both ways you'll get larger single disk(size would depend from the RAID level you choose) for which you'll need to go to step 2 and farther. It's worth mentioning that there is another way to get larger than single disk usable space from multiple disks called Logical Volume Manager or LVM. It's more sophisticated than MDM and allows to create FS snapshots and add extra disk space to the volume without need to create additional mountpoints.
Whatever you choose you'll need to create a partition table on a new disk/LVM volume/MDM disk. Here you need to make another choice - what type of partition table to use, MBR or GPT. Check Partitioning HOWTO for more details, but in general I'd recommend GPT for large non-bootable disks.
Same HOWTO will tell you, how create partition(s) on the selected disk. At this point you'll get devices like /dev/sdb1, etc.
Then you can go to step 4, the one you already tried:
# mkfs.ext4 /dev/sdb1
That should succeed now and you'll be able to get UUID of a new FS with blkid. Add obtained UUID to your /etc/fstab file and mount newly created FS to it's mount point.

It seems to me that you must create partitions on disks.
Think about storing your data. You have similar disks. It must be raid? If it must be raid, what type of raid it must be?
You can create partition with fdisk or some alternatives (gparted, cfdisk and so on).
There are a lot information in internet and manuals.
May be you need LVM? Some people say that it may slow down your database, but it gives you opportunity to get snapshots.
After creating partitions you can create filesystem and can mount it.
Usually people recommend to use XFS or Ext4 for databases.
And don't forget to set right mount flags to your filestystem.
noatime,nodiratime and barrier=0 will improve performance, but with barrier=0 in some cases you can loose your data. In case of Ext4 look at data (may be in your case you can set it in ordered).
UPD: may be this question must be in superuser or unix section?

You supposed to create partition with utility like the fdisk, cfdisk, gparted or partitionmanager before you can format it.

Related

Partitions in Linux

I've just learnt about backup and restore on Ubuntu. I have some questions below.
When we've set up Ubuntu successfully, how many partitions have been created? I checked on Terminal by using parted -l and see that there're 3 parts. I typed lsblk and it seems there's a difference in size of /dev/sda2 (extended partition) between two commands. Can I have the explanation?
Does mkfs command create a logical partition? I know that mkfs means make a file system, but a file system is created when mounting with a partition.
Here some images.
The difference is because of extended partition type of dev/sda2 device. More explanation is given here
By definition, mkfs says mkfs is used to build a Linux file system on a device, usually a hard disk partition. This means, you have to use either fdisk or parted to partition a hard disk into primary or extended or logical type & then use mkfs to build either ext4 or ext3 or xfs filesystem or whatever which depends on your need.
Software people calculate disk size as multiples of 1024. But some use multiples of 1000. In your case, parted is probably using 1000 while lsblk is using 1024.
You can not use mkfs to partition disk. You can make a filesystem with it once the disk is already partitioned.

Possible to pvmove & vgreduce in LVM if PVs are allocated to Xfs free space?

I have a ~250 TB Xfs file system, distributed across several disks (PVs) via LVM.
I've moved most of the data to another server. The remaining data (~60 TB) would easily fit on just PV.
I would like to decommission all but one disk in my VG. The trouble is my LV is an Xfs, and Xfs filesystem shrinking is unsupported. So no matter how “empty” the filesystem is, I can’t use pvmove to take extents off the PV, because it’s still being “used” by free space in Xfs, and thus can’t vgreduce it.
All the tutorials on how to do this, e.g. https://yallalabs.com/linux/how-to-reduce-shrink-the-size-of-a-lvm-partition-formatted-with-xfs-filesystem/ , boil down to "back up your data, reformat, restore".
Is that truly the only option?
I have tried this for xfs long back. Don't have commands handy, but did below:
Take backup of current XFS file system
Remove the LV
Create new LV with required size
Restore the XFS backup

How to resize partition size while the middle partition is the BIOS Boot?

I used Clonezilla to restore an old system to a larger hard disk. However, when I do all my job, I found my first partition doesn't use all the disk space.
I know the method to resize the partition size by using fdisk, however, I noticed that there is a BIOS boot partition between the first partition and free space. Now I don't know how to deal with it.
So I want to ask how to expand my first partition to use most of my free space in this disk.
The second partition type is BIOS Boot, Contents: Unknown
To be sure it's used (or not used), you can :
# back it up
dd if=/dev/sda2 of=$HOME/sda2.dd
# wipe it
dd if=/dev/zero of=/dev/sda2
# reboot
If reboot goes normally, that mean the partition is not used.
You can then remove sda2 and extend sda1.
I finally figure it out.
I made a live boot Linux mint USB stick, then boot into the Linux Mint on USB stick. Start the GParted, then move the /dev/sda2 to the end of the hard drive. Than expand the /dev/sda1 partition to use the free space.
Then I got this:
But be sure to back up all your data if you want to do the same thing.

What is the general sizing number for /dev partition on RHEL

Please check the below description:
Red Hat Enterprise Linux uses a naming scheme that is file-based, with file names in the form of /dev/xxyN.
Where,
xx:
The first two letters of the partition name indicate the type of device on which the partition resides, usually sd.
y:
This letter indicates which device the partition is on. For example, /dev/sda for the first hard disk, /dev/sdb for the second, and so on.
N:
The final number denotes the partition. The first four (primary or extended) partitions are numbered 1 through 4. Logical partitions start at 5. So, for example, /dev/sda3 is the third primary or extended partition on the first hard disk, and /dev/sdb6 is the second logical partition on the second hard disk.
In Red Hat Enterprise Linux each partition is used to form part of the storage necessary to support a single set of files and directories. Mounting a partition makes its storage available starting at the specified directory (known as a mount point).
For example, if partition /dev/sda5 is mounted on /usr/, that would mean that all files and directories under /usr/ physically reside on /dev/sda5. So the file /usr/share/doc/FAQ/txt/Linux-FAQ would be stored on /dev/sda5, while the file /etc/gdm/custom.conf would not. It is also possible that one or more directories below /usr/ would be mount points for other partitions. For instance, a partition (say, /dev/sda7) could be mounted on /usr/local/, meaning that /usr/local/man/whatis would then reside on /dev/sda7 rather than /dev/sda5.
Generally speaking, the disk spacing for /dev partition depends on number and size of the partitions (both primary and logical)to be used by operating system. However, there is no one right answer to this question. It depends on your needs and requirements.
My question is, Is there any affect to the initial partition memory (say, we given 32 GB to /dev partition while installing RHEL OS), if we are adding more harddisk memories(say in 100's of GB's) to /dev partition.
You don't create partitions for /dev. It's in memory, and managed fully automatically by the kernel. /dev exists to expose kernel objects such as devices to userspace, it is transient and doesn't require backing storage on disk.
if you run ls -l /dev/sda1, you will see that the first letter in the permission block says b. b = block-device. This is a special file that if stored on disk, only would hold two special numbers (called major and minor, usually stored together with the file-permissions). When you try to open this special file, the kernel will see that it is a "block" device and look up and major and minor numbers to find the matching physical driver that actually contains this data. Your read/write/ioctl calls will then be redirected to this driver.

lvm: create snapshot between volume groups

is there a way to create a snapshot of a logical volume (lv1) that resides into volume group vgA inside a different volume group (say vgB)?
i have my root logical volume in volume group vgA on the SSD and i want to take a snapshot of the volume on the second volume grout vgB that sits onto the mechanical hard disk, so i tried to execute
lvcreate -L 10G -s -n vgB/rootSnapshot vgA/rootVolume
and some other variants but had no luck..
The snapshot volume must reside on the same VG as lv1.
For your situation, you may want to consider creating one VG (vgA) that spans over two PVs (pv1 for SSD, and pv2 for mechanical hard disk). Then you can create lv1 on pv1 and lvsnap on pv2.
lvcreate -L 100G -n lv1 vgA /dev/pv1
lvcreate -L 10G -s -n lvsnap /dev/vgA/lv1 /dev/pv2
Only want to say that limiting the snapshot in the same volume group as it's orignal lv really makes the idea of "logical" volume degraded.
For example, I use two hard drives with a RAID card to form a RAID1 disk and manage all it's physical space with volume group VG_SYS, and create my system volume and install my OS within it.Then I use another two drives to form a RAID0 disk and build a VG_DATA volume group on it, planning to use it as storage for unimportant data and snapshot.
However, I can't create snapshot volume in VG_DATA due to the limitation of LVM. Of course I can extend my VG_SYS onto my RAID0 drive and dedicate those pvs from RAID0 drive to my snapshot volume. But that would make my intention vague which separating logical volumes into important system volume group (redundancy guaranteed by RAID1) and unimportant quickly updated data volume group (RAID0 to increase I/O efficiency). Snapshots are meant to be updated and recycled very quickly so they don't need any redundancy. If a snapshot happens to be broken you just need to rebuild another one -- it's unlikely both your original volume and snapshot are broken at the same time.
It's not possible with LVM, specifically lvcreate does not support it. However, it's possible if you use device mapper directly (via dmsetup).
See here:
https://www.kernel.org/doc/html/latest/admin-guide/device-mapper/snapshot.html#how-snapshot-is-used-by-lvm2
https://www.man7.org/linux/man-pages/man8/dmsetup.8.html

Resources