Month: October 2021

Buzzing noise and hard to turn on from iMac 27′

Buzzing Noise from iMac 27'

Got buzzing noise from top left corner, and very hard to turn on, power button may or may not response.

The fan noise also comes from bottom right corner, thinking to replace a new one.

Issues

The power button got issue long ago, sometimes can not work, sometimes can. I think after disconnected from power, maybe will be ok later. I thought it could be bottom connection issue.

After moved iMac into a quiet room, I heard buzzing noise from top left corner, I started believe the power supply got issue.

Plan

Replace power supply later together with fan.

References

IMAC Buzzing Noise From Top Left Corner FIXED!! / Replace Power Supply

TODO: Move dataset to another zpool in TrueNAS

Move dataset to another zpool in TrueNAS

In Synology, move share folder to another volume is quite easy, can be done via UI interface. In TrueNAS, I could not find such task can be selected.

Duplicate dataset from snapshot

The workable solution is utilize the zfs command to duplicate in SSH environment, then export old pool and import new one.

First make a snapshot poolX/dataset@initial, then use following command duplicate zfs dataset snapshot to new zpool.

zfs send poolX/dataset@initial | zfs recv -F poolY/dataset

Update new dataset

Then make another snapshot poolX/dataset@incremental, then use following command update zfs dataset snapshot to new zpool.

zfs send -i initial poolX/dataset@incremental | zfs recv poolY/dataset

Activate new dataset

To make the new dataset usable, rollback snapshot needs to be performed for new dataset.

Update share

Change shared point to use new pool.

Update client

This is only required if client used server filesystem structure, such as NFS.

References

Migrate to smaller disk
*Note: pv (Pipe Viewer) command is not installed in TrueNAS by default.

Error replace hard disk in zpool in TrueNAS

Error replace hard disk in zpool in TrueNAS

Got following error when trying to replace hard disk in zpool. Reboot is required.

middlewared.service_exception.CallError: [EFAULT] Partition type 6a898cc3-1dd2-11b2-99a6-080020736631 not found on sda

Partition exists

First issue with the partition which exists in the old hard disk. Use fdisk to remove all partitions. But still could not replace.

Use force option

Then click on force check box, the replacing was started, but stopped at 15%. Tried many times, but still failed. Search google, people got same issue, but they said sudden worked.

Run partprob

Run partprob, error shows the kernel didn't know the new partition table, reboot is required.

Check partition after reboot

After reboot, checked partition table, found TrueNAS had updated partition as others, which has one 2GB swap. Then force replace hard disk in pool again, then worked

Conclution

This is TrueNAS bug, which didn't close devices in kernel before repartition hard disk, this caused partition is opened and could not reread the new partition table into kernel.

Solution

Reboot

References

Cant create Pool on TrueNAS Scale (it does work on TrueNAS Core under same Hardware)
Cant create Pool on TrueNas Scale

Application Stopped due to upstream unreachable

Application Stopped due to upstream unreachable

During Chef Server troubleshooting time, found chef is unreachable from localhost

Description

  • Nginx was shown as started in chef-server-ctl status command, pid could be found
  • TCP port 443 was inaccessable from localhost.
  • Reboot server, but still the same issue
  • Used ps -ef | grep nginx, found nginx is running without indication of master
  • Run nginx command line which found in ps
  • Shows upstream server and port was not reachable, which is automate server

Result

  • Can not find IP address, then add IP and host into /etc/host file, result shows

    • NGINX running with master indicator
    • TCP port 443 was listening
  • Still can not reach upstream server

Consolution

The problem could be related to following issues caused application stopped due to no IP can be found for upstream servers.

  • Routing issue
  • Firewall issue

Process Listening on a Particular Port in Linux

Process Listening on a Particular Port in Linux

These commands might not workable in some Unix like systems.

Using netstat

netstat -ltnp
netstat -peanut

lsof

lsof -i :80

fuser

fuser 80/tcp

ss


ss -nlp
``

## References

[3 Ways to Find Out Which Process Listening on a Particular Port](https://www.tecmint.com/find-out-which-process-listening-on-a-particular-port/)

Sort posts by last updated date in WordPress

Sort posts by last updated date in WordPress

Solution

In recent post list, the date of sorting is based on published date, so the updates will never be shown. To change this behavior, following code can be appended into functions.php to archive the sorting by last updated date.

function lmt_orderby_modified_posts( $query ) {
    if( $query->is_main_query() && !is_admin() ) {
        if ( $query->is_home() || $query->is_category() || $query->is_tag() ) {
            $query->set( 'orderby', 'modified' );
            $query->set( 'order', 'desc' );
        }
    }
}
add_action( 'pre_get_posts', 'lmt_orderby_modified_posts' );

Issue

There is an issue after changed sorting and modified post day, the archives will still be under published date, which can be comfusing.

If there is a way change permalink structure based on last updated date, then could be much simple.

References

Sort posts by modified date in the frontend
Using Permalinks
Simple Guide to Changing Your Permalinks Without Breaking Your WordPress Site

Last updated date in WordPress

Last updated date in WordPress

There are a few methods to display last updated in WordPress

Change post date to last updated date

But default, post date is published date, if like to change it to last updated date, add additional CSS as below.

/* for post modified */
.entry-date.published { display: none; }
.updated:not(.published) { display: inline-block; }

/* for post that never been modified, theme uses .updated */
.entry-date.published.updated { display: inline-block; }

Change functions.php

function my_last_updated_date( $content ) {
    $u_time = get_the_time('U');
    $u_modified_time = get_the_modified_time('U');

    if ($u_modified_time >= $u_time + 86400) {
        $updated_date = get_the_modified_time('F jS, Y');
        $updated_time = get_the_modified_time('h:i a');
        $custom_content .= '<p class="last-updated entry-meta">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';
    }

    $custom_content .= $content;
    return $custom_content;
}
add_filter( 'the_content', 'my_last_updated_date' );

Change template-tags.php

This is the PHP way to modify the code to display dates.

References

How to replace published date?

iMac 27″ Mid 2011 OS reinstallation

iMac 27" Mid 2011 OS reinstallation

In order to reinstall OS, I searched Internet, and no one tell the truth, let me spent a few hours. I'm also not sure my method will work later or not. Need to think a way to create local bootable disk.

Keyboard and Mouse

I don't have wired apple keyboard and mouse, so used Windows keyboard. It doesn't have Command key, but searching internet, found the Intel iMac can use Command or Alt. Yes, Alt works, can display boot option.

Installation Method

Missing installation CD (Failed)

After a few relocation, I could not find the installation CD, it is at least hard to find, decided to create an installation USB.

Installation USB (Failed)

My new iMac mini has OS Big Sur, I tried methods given by Apple, none of them can work.

I created Big Sur bootable USB, but when tried to install, gave me stop sign.

I tried to click the links to download old MacOS from Apple, they don't work at all.

I tried to download OS image from other website, they can not be executed and run Apple given command, because they are for different OS.

I tried use Daemon Tools to create bootable USB from dmg file, in fact, not working.

Internet (Good)

When I kept finding methods to create bootable image, suddenly, the iMac display installation utilities after boot, which means installation can be continue without installation media, this is good feature of iMac.

Disk to be installed

Got funny issue, can not detect my SSD, I thought the SATA connection issue. Open it and reconnected it, tested on external USB, suddenly found the disk can be detected by Disk Utility. Then thought again, noticed that the disk needs to be erased.

OS upgrade and patching

After installation completed, it is running Mount Lion, very old OS, then App Store update got issue, can not update software patch.

After search internet, found High Sierra can be installed, then clicked on Apple OS installation link which was work before, it works.

Not completed, there are quite number of patches to be installed, although take long time, the actual installation time reported by installation process is much longer, about 15 mintues reduced to two or three minutes, this is the benefit of SSD disk.

Backup

To avoid spending too much time next time, I decided to create installation media image and perform backup.

After opened time machine disk selection window, the AFP enabled NAS immediately appear, but not the SMB only NAS. Manual mapping/accessing of disk is required before Time machine could see it.

El Capitan:

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia -

Appendices

Media Creation

The commands are given by Apple as below for media creation.

Beware: They can not work with OS which is different than current.

Big Sur:*

sudo /Applications/Install\ macOS\ Big\ Sur.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

Catalina:*

sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

Mojave:*

sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

High Sierra:*

sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume

References

How to create a bootable installer for macOS

Bootstrap source map missing

Bootstrap source map missing

Description

When open web developement tools in web browser, followning error could appear.

Source map error: request failed with status 404
Resource URL: https://domainname.com/.../bootstrap.css?ver=4.4.1
Source Map URL: bootstrap.css.map

Fixes

Method 1

This file can be download from bootstrap web page Bootstrap v4.4.1, and put it into same folder as bootstrap.css.

Method 2

Remove comments like /# sourceMappingURL=bootstrap.min.css.map / in bootstrap.min.css, bootstrap.min.js.

Reason

Source map files are generated automatically during files minification/compiling process, and they are not needed for the production.