Move OS files to the begin of the disk - operating-system

I would like to know if it's possible to move the files on a given partition to the begin of the disk, where the read/writes are faster.
I currently have Windows Vista installed on the first partition of the disk with a few more partitions for work related files and other stuff.
Would this guarantee that the OS partition (which was the first to be created) is located at the begin of the disk?
Would a defrag program help with this or the various partitions limit the location of the files on the disk?

No, it's not possible. Physical partitions separate a disk into circular regions. The first partition occupies the outer ring of the disk, and the next partition occupies the ring inside that one. You can move files within a partition, but all the files of one partition come before any files of any other partition.
If partitions were wedge-shaped, then what you request would be possible.

Ultimate Defrag (sry, no link, just google it up, it's free) has the option to move recent used files to the fastest area of the disk
Greetz,
GHad

Related

How does Kafka guarantee sequential disk access?

I'm a newbie for Kafka. When I read the documentation of Kafka, I saw that Kafka is performing well because of sequential disk access.
But how is that possible? In Java(or something else), If I use File I/O, OS will handle it appropriately. However, I can't know if OS store the files I want to store in multiple sectors or in contiguous sectors. So, Kafka cannot always say that sequential disk access occurs in my opinion.
Am I true or not?
Kafka does not always access disk sequentially but it does some things that make it much more likely that disk access is often sequential. All Kafka messages are stored in larger segment files (1GB each by default) and since Kafka messages are not deleted when consumed (like in other message brokers) Kafka will not end up creating a fragmented filesystem over time by continuously creating and deleting many variable length files. Instead it creates segment files and then appends to that file until it reaches 1GB (a configurable limit). Only when all messages in the segment expire will it delete the entire 1GB segment. This means that often these 1GB sections of disk are actually laid out as contiguous blocks. It is a recommended best practice to keep these Kafka commit log files on a dedicated filesystem so it does not get fragmented by other apps reading and writing variable length files into the same filesystem. More importantly most reading an writing to these segment files is sequential and goes through OS page cache so as to reduce disk I/O even further by caching the most often accessed pages in memory. This is why it is a recommendation to tune the kernel to set swappiness to 1 to reduce the likelihood that these cached pages would get swapped out of memory.

Why does the sequential write to a journal file speed up if it is in a different file system?

As per MongoDB documentation at http://docs.mongodb.org/manual/core/journaling,
To speed the frequent sequential writes that occur to the current
journal file, you can ensure that the journal directory is on a
different filesystem
storing the journal file on a different file system speeds things up. Is it because two different hard disk spindles are at work? Just wanted to understand the mechanics of this optimization tip.
Yes,
If you are using physical rotating hard drives, there is significant performance benefit from separating the journal activities onto a separate (preferably dedicated) physical drive.
The benefits are not the same if you're using SAN hardware. And to an extent are lessened by larger drive caches available in modern hard drives. And it's a different story again with SSD.
The main factor with spinning disks is seek time - the time that it takes for the read/write head to get to the right part of the disk. Hard disks are arranged with circular tracks. To get to a specific block on the disk, the head moves to the right track, and the disk spins around to the right place (the disks keep spinning of course, so it's simply a matter of waiting for the right place to come around).
This doesn't take much time, but when it's happening a lot it adds up.
When you have the primary activity and the journal activity on the same drive, the head has to rapidly move between the two (many, really) locations that the system needs to look at.
If you have your journalling on another physical drive, then the head on that drive can be almost (or perhaps more accurately, relatively) static, with the ability to more rapidly access the correct track / location required. Meanwhile the other drive (with the primary activity on it) will be more efficient also, because the head will not be constantly seeking back to the where the journal entries are being written between the other activities required to keep the database running.
This benefit applies to most database systems and many other applications where there is a constant sequential writing to disk going on at the same time as other mixed disk activity.
You don't get the same profile if you're using SAN, because even if it appears to be separate file systems, it's actually likely to be striped across many drives which are both cached and shared.
SSD has a different profile also, because there is no physical seek time.

Assigning a letter to OEM Partition

I'm trying to do an exact clone of my laptop. There is an OEM partition that I can't assign a letter to. I'm using DISM, which uses the drive letters to know what to capture.
I was wondering if there was a way to assign a letter to the OEM partition. I've looked at diskpart and assign letter does not work for OEM partitions. I was wondering if there was a work around.
Also I looked into partitions and volumes and it was a bit confusing, how are they correlated? Are partitions subsets of volumes?
EDIT: I'm pretty sure partitions are subsets of volumes, but I can't find verification anywhere.
Partitions are storage units used to divide physical disks into smaller, independent parts. Basically they're containers for filesystems. Volumes are storage units with a filesystem. A volume can be inside a partition, but it's also possible for a volume to span multiple partitions.
As for assigning a drive letter to that particular partition: you need to determine the type of the filesystem inside that partition first. GParted might prove helpful there. Windows can only mount FAT(32) and NTFS volumes. For other filesystems (like Ext2/3/4 or XFS) you're going to need 3rd party tools.

OS bootstraping process

I try to understand os bootstraping process. Some questions are not clear to me.
One of them is :
How does bootstrap code in Volume boot record know about absolute LBA address of 0 sector of patition where Volume boot record resides?
Within the VBR is a structure called a BIOS Parameter Block, named after the BIOS, the bottom-half of the traditional MS-DOS kernel structure. Within the BIOS Parameter Block is a field denoting the number of hidden sectors between the partition and the (MBR-style) partition table entry that encloses it. The VBR code simply reads that field out of itself and adds it to the Volume-relative Block Address to produce the LBA to read from the disc.
This is why it is impossible to boot operating systems such as Windows NT, MS/PC/DR-DOS, and OS/2 from secondary partitions directly, without assistance. In primary partitions, the BPB field is simply the start LBA of the start of the volume, because the partition table that it is relative to is the primary MBR in block #0 of the disc, and everything works. In secondary partitions, because of a quirk of MS-DOS version 3 that everyone has had to remain compatible with ever since, the BPB field is only the offset of the "logical drive" within the "extended partition" containing it, and the boot code doesn't work because it looks for the rest of the boot volume in completely the wrong place on the disc.
Boot managers provide assistance by fixing up the BPB on the fly. The VBR code of course reads the in-memory copy of itself, not the on-disc copy. So boot managers simply adjust the field of the BPB for secondary partitions to the correct absolute value, as they are loading the VBR into memory. Then everything works.

Hard drive device name on Solaris

I need to figure out the hard drive name for a solaris box and it is not clear to me what the device name is. On linux, it would be something like /dev/hda or /dev/sda, but on solaris I am getting a bit lost in the partitions and what the device is called. I think that entries like /dev/rdsk/c0t0d0s0 are the partitions, how is the whole hard drive referenced?
/dev/rdsk/c0t0d0s0 means Controller 0, SCSI target (ID) 0, and s means Slice (partition) 0.
Typically, by convention, s2 is the entire disk. This partition overlaps with the other partitions.
prtvtoc /dev/rdsk/c0t0d0s0 will show you the partition table for the disk, to make sure.
If you run Solaris on non SPARC hardware and don't use EFI, the whole hard drive is not c0t0d0s2 but c0t0d0p0, s2 is in that case just the Solaris primary partition.
What do you want to do to the whole disk? Look at the EXAMPLES section of the man page for the command in question to see how much of a disk name the command requires.
zpool doesn't require a partition, as in: c0t0d0
newfs does: c0t0d0s0
dd would use the whole disk partition: c0t0d0s2
Note: s2 as the entire disk is just a convention. A root user can use the Solaris format command and change the extent of any of the partitions.
The comments about slice 2 are only correct for drives with an SMI label.
If the drive is greater than 1TB, or if the drive has been used for ZFS, the drive will have an EFI label and slice 2 will NOT be the entire disk. With an EFI label, slice 2 is "just another slice". You would then refer to the whole disk by using the device name without a slice, e.g. c0t0d0.
There are two types for disk label, one is SMI(vtoc), the other is GPT(EFI).
On X86 platform and the disk is SMI labeled(default behavior):
cXtXdXp0 is the whole physical disk
cXtXdXp1-cXtXdXp4 are primary partitions, included the solaris partitions.
cXtXdXs0-cXtXdXs8 are the partitions(slices) of the activate Solaris partitions.
cXtXdXs2 is the whole activate Solaris partition, maybe not the whole disk.
Hope I am clear.
/Meng
C0 - Controller
T0 - Target
D0 - Disk
S- - Slice
c0t0d0s0 is the entire drive. The breakdown is:
/dev/[r]dsk/c C t A d0s S
...where C is the controller number, A is the SCSI address, and S is the "slice". Slice 0 is the whole disk; the other slices are the partition numbers.
See this for more info.
cXtYdZs2 is the whole drive. period.